示例#1
0
    void Update()
    {
// yaw - Rotation along the Horizontal
        yaw += speedH * accCam.Horizontal();
// pitch - Rotation along the Vertical
        pitch = speedV * accCam.Vertical();

// Clamp the Vertical Rotation Values - To Avoid full rotation along Vertical
        pitch = Mathf.Clamp(pitch, vMin, vMax);
// Assign the Values to the Camera
        transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
    }
 // Update - Runs before every frame refresh - UNITY
 void Update()
 {
     // Rotate the Player as the Camera Rotates [Horizontal Only]
     yaw += speedH * accCam.Horizontal();
     transform.eulerAngles = new Vector3(0.0f, yaw, 0.0f);
     // If Player is on Ground - Calculate Move Direction, Check for Jump Input
     if (controller.isGrounded)
     {
         moveDirection  = new Vector3(vjMov.Horizontal(), 0, vjMov.Vertical());
         moveDirection  = transform.TransformDirection(moveDirection);
         moveDirection *= speed;
         if (JumpInput() == true)
         {
             JumpInput(false);
             moveDirection.y = jumpSpeed;
         }
     }
     // Effect of Gravity
     moveDirection.y -= gravity * Time.deltaTime;
     // Move Player in Calculated Direction
     controller.Move(moveDirection * Time.deltaTime);
 }