Пример #1
0
    // --------------------------------------------------------------------
    // To handle movement.
    public void ManageMovement(float h, float v)
    {
        if (anim.GetBool(state.isClimbingBool))
        {
            return;
        }
        // Find the new forward and right vectors to move along.
        Vector3 forwardMove    = Vector3.Cross(Camera.main.transform.right, Vector3.up);
        Vector3 horizontalMove = Camera.main.transform.right;

        // Multiply the direction vectors by the Input.GetAxis floats.
        movement = forwardMove * v + horizontalMove * h;

        // Normalise the movement vector and make it proportional to the speed per second.
        movement = movement.normalized * speed * Time.deltaTime;
        // Set velocity for animation states
        state.SetVelocity(movement);
        // Move the player to it's current position plus this movement.
        rigidbody.MovePosition(transform.position + movement);
    }