private void FixedUpdate()
    {
        float h = CrossPlatformInputManager.GetAxis("Horizontal");

        float v = CrossPlatformInputManager.GetAxis("Vertical");

        bool crouch = Input.GetKey(KeyCode.C);

        if (Camera != null)
        {
            CameraForward = Vector3.Scale(Camera.forward, new Vector3(1, 0, 1)).normalized;
            Direction     = v * CameraForward + h * Camera.right;
        }
        else
        {
            Direction = v * Vector3.forward + h * Vector3.right;
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            Direction *= 0.5f;
        }

        Character.Move(Direction, crouch, Jump);
        Jump = false;
    }
Exemplo n.º 2
0
    private void Update()
    {
        if (Target != null)
        {
            Agent.SetDestination(Target.position);
        }

        if (Agent.remainingDistance > Agent.stoppingDistance)
        {
            Controller.Move(Agent.desiredVelocity, false, false);
        }
        else
        {
            Controller.Move(Vector3.zero, false, false);
        }
    }