예제 #1
0
        // Update is called once per frame.
        void Update()
        {
            // If the rig, main camera, and character controller are valid.
            if (Rig != null && MainCamera != null && Character != null)
            {
                // Update the character controller's height.
                Character.height = MainCamera.transform.position.y - Rig.transform.position.y + offset;

                // Update the character controller's center.
                Vector3 center = Character.center;
                center.y         = -Character.height / 2.0f;
                Character.center = center;

                Vector3 newPos = MainCamera.transform.position;

                // Maintain Old RigidBody Y Position
                newPos.y = RigidBodyCharacter.position.y;

                RigidBodyCharacter.MovePosition(newPos);

                // Begin locomotion.
                if (CanBeginLocomotion() && BeginLocomotion())
                {
                    // Determine the character controller's world location.
                    Vector3 characterLocation = Character.transform.position;

                    characterLocation.y -= offset;

                    if (!VirtualBodyScript.CollisionFlag)
                    {
                        characterLocation.x = MainCamera.transform.position.x;
                        characterLocation.z = MainCamera.transform.position.z;
                    }

                    // Move the rig and camera to the character controller's world location.
                    Rig.MoveCameraToWorldLocation(characterLocation);
                    // End locomotion.
                    EndLocomotion();
                }
            }
        }
 void Start()
 {
     rbc = GetComponent<RigidBodyCharacter>();
 }