예제 #1
0
        void CheckJump()
        {
            Vector3 up           = -Input.gyro.gravity;
            float   upwardsAccel = StepDetector.GetUpwardsAcceleration();

            bool jumpInputted = (upwardsAccel > jumpDetectionThreshold) || Input.GetKey(KeyCode.Space);

            if ((onGround || _jumpGracePeriodTimer > 0) && _jumpCooldownTimer <= 0 && jumpInputted)
            {
                _jumpCooldownTimer = _jumpCooldown;
                Vector3 curVel = _rigidbody.velocity;
                curVel.y            = 5;
                _rigidbody.velocity = curVel;

                onGround       = false;
                dampingEnabled = false;
            }
        }
        void Start()
        {
            _rigidbody           = GetComponent <Rigidbody>();
            _characterController = GetComponent <CharacterController>();

            if (controllerType == ControllerType.RigidBody && _rigidbody == null)
            {
                Debug.Log("No Rigidbody component found on the WIP Controller object, setting ControllerType to manual");
                controllerType = ControllerType.Manual;
            }

            if (controllerType == ControllerType.CharacterController && _characterController == null)
            {
                Debug.Log("No CharacterController component found on the WIP Controller object, setting ControllerType to manual");
                controllerType = ControllerType.Manual;
            }

            StepDetector.AddStepAction(OnStep);
        }
예제 #3
0
 void Awake()
 {
     instance = this;
 }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     StepDetector.AddStepAction(OnStep);
 }