예제 #1
0
        void Update()
        {
            if (Input.GetButtonDown("Possess"))
            {
                if (_cc.IsPossessing())
                {
                    _cc.UnPossess();
                    _mc = null;
                }
                else
                {
                    RaycastHit hitInfo = new RaycastHit();

                    if (Physics.Raycast(transform.position, transform.forward, out hitInfo))
                    {
                        _mc = hitInfo.transform.gameObject.GetComponent <IMovementController>();

                        if (_mc != null)
                        {
                            _cc.Possess(hitInfo.transform.gameObject);
                        }
                    }
                }
            }

            // For some reason this doesn't update immediately. There is some stutter when moving the camera.
            if (_mc != null)
            {
                if (Input.GetButtonDown("Jump"))
                {
                    _mc.Jump();
                }

                if (!_mc.ControlsOrientation())
                {
                    Vector3 dir = transform.forward;
                    dir.y = 0.0f;

                    _mc.GetGameObject().transform.LookAt(_mc.GetGameObject().transform.position + dir);
                }
            }
        }
 public void Jump()
 {
     movementController.Jump();
 }