public void CheckGround()
    {
        _ColliderHits = Physics.OverlapBox(_PlayerTransform.position, _GroundCheckSize, _PlayerTransform.rotation, _GroundLayer);
        if (_ColliderHits.Length > 0)
        {
            if (_IsGrounded)
            {
                return;
            }                                                        //Don't continuously call state controller with repetitive messages that the player is grounded
            _ProxyFall.ProxyOff();                                   //Player is grounded

            Vector3 resetYVelocity = _PhysicsPlayer.CurrentVelocity; //When the player hits the ground ensure that their y velocity is set to zero again
            resetYVelocity.y = 0.0f;
            _PhysicsPlayer.CurrentVelocity = resetYVelocity;

            _IsGrounded = true;
        }
        else
        {
            if (!_IsGrounded)
            {
                return;
            }                     //Don't continuously call state controller with repetitive messages that the player is falling
            _ProxyFall.ProxyOn(); //Player is not grounded
            _IsGrounded = false;
        }
    }
Esempio n. 2
0
 public void AnalogCancel()
 {
     _ProxyLook.ProxyOff();
     _ObserverController.Notify(Vector2.zero); //Notify all observers that the analog input from look has changed
 }
Esempio n. 3
0
 public void AnalogCancel()
 {
     _ObserverController.Notify(Vector2.zero); //Notify all observers that the analog input from walk has changed
     _ProxyWalk.ProxyOff();                    //Inform the walk state proxy that the player wants to leave the walking state
 }