コード例 #1
0
 // Update is called once per frame
 void Update()
 {
     if (!HUDController)
     {
         HUDController = ref_GameController.m_HUDController;
     }
     if (!interacting)
     {
         if (GC.HasPlanet())
         {
             CalculateGroundMovement();
             CalculateGroundRotation();
             Animation(true);
         }
         else
         {
             CalculateSpaceMovement();
             CalculateSpaceRotation();
         }
     }
     else
     {
         Animation(false);
     }
 }
コード例 #2
0
    void LateUpdate()
    {
        if (!m_CharacterController.interacting)
        {
            transform.position = m_ObjectToFollow.position;

            transform.rotation = m_ObjectToFollow.rotation;

            if (CameraArm)
            {
                x += Input.GetAxis("Mouse X") * xSpeed * distance;
                y -= Input.GetAxis("Mouse Y") * ySpeed;

                if (GC && GC.HasPlanet())
                {
                    y = ClampAngle(y, yMinLimit, yMaxLimit);
                }

                Quaternion rotation = Quaternion.Euler(y, x, 0);

                distance = Mathf.Clamp(distance - Input.GetAxis("Mouse ScrollWheel") * 5, distanceMin, distanceMax);

                RaycastHit hit;
                if (Physics.Linecast(CameraArm.position, transform.position, out hit))
                {
                    distance -= hit.distance;
                }

                //Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
                //Vector3 position = rotation * negDistance + Camera.position;
                //
                //Camera.position = position;

                CameraArm.localRotation = rotation;
            }
        }
    }