Exemple #1
0
    void Update()
    {
        //Calculate movement velocity as a 3d Vector
        float xMov = Input.GetAxisRaw("Horizontal");
        float yMov = Input.GetAxisRaw("Vertical");

        Vector3 movHorizontal = transform.right * xMov;
        Vector3 movVertical   = transform.forward * yMov;
        Vector3 velocity      = (movHorizontal + movVertical)
                                .normalized * speed;

        motor.Move(velocity);
        //animation
        Animating(xMov, yMov);
        //Rotation(turning around)
        float   yRot     = Input.GetAxisRaw("Mouse X");
        Vector3 rotation = new Vector3(0f, yRot, 0f) * lookSensitivity;

        motor.Rotate(rotation);
        //Camera Rotation(turning around)
        float   xRot        = Input.GetAxisRaw("Mouse Y");
        Vector3 camrotation = new Vector3(xRot, 0f, 0f) * lookSensitivity;

        motor.CameraRotate(camrotation);
    }