コード例 #1
0
    public static CCJumpToAction GetSSAction(Vector3 target, float speed, GameObject gameobject)
    {
        CCJumpToAction action = ScriptableObject.CreateInstance <CCJumpToAction> ();

        action.gameobject = gameobject;
        action.transform  = gameobject.transform;
        action.target     = target;
        action.speedx     = speed * ((target.x < action.transform.position.x) ? -1 : 1);
        float deltaTime = (target.x - action.transform.position.x) / action.speedx;

        action.speedx *= deltaTime * 2;
        deltaTime      = 0.5F;
        action.speedy  = Mathf.Abs((target.y - action.transform.position.y) / deltaTime + 0.5F * gravity * deltaTime);
        return(action);
    }
コード例 #2
0
    public void MoveCharacter(ICharacterController character, Vector3 destination)
    {
        CCJumpToAction action = CCJumpToAction.GetSSAction(destination, defaultSpeed, character.character);

        RunAction(action, this);
    }