Exemplo n.º 1
0
    private void UpdateParameters()
    {
        IsGrounded.Value        = charMotor.GroundingStatus.FoundAnyGround;
        IsOnSlidebleSlope.Value = StandingOnSlideableSlope();
        BaseVelocity.Value      = charMotor.BaseVelocity;
        groundInfo             = GetGroundInfo();
        DistanceToGround.Value = groundInfo.distance;
        GroundSlamCooldownTimer.UpdateTime();

        if (!LastGroundingStatus.FoundAnyGround && GroundingStatus.FoundAnyGround)
        {
            BecameGrounded.Activate();
        }

        else if (LastGroundingStatus.FoundAnyGround && !GroundingStatus.FoundAnyGround)
        {
            BecameUngrounded.Activate();
        }
    }
Exemplo n.º 2
0
        protected override void UpdateRotation(Quaternion currentRotation)
        {
            Quaternion newRotation;
            Vector3    lookDirection     = playerController.transform.forward;
            Vector3    velocityDirection = dirOnSlopeGizmo;

            GroundingInfo groundInfo = playerController.GroundInfo;

            if (Mathf.Approximately(velocityDirection.magnitude, 0f))
            {
                newRotation = currentRotation;
            }
            else
            {
                newRotation = Quaternion.LookRotation(velocityDirection.xoz(), Vector3.up);
            }
            //newRotation = Quaternion.LookRotation(velocityDirection, playerController.GroundingStatus.GroundNormal);


            NewRotationOut.Value = newRotation;
        }
Exemplo n.º 3
0
    //Cast downward from collider to get info about ground below
    private GroundingInfo GetGroundInfo()
    {
        GroundingInfo info = new GroundingInfo();
        RaycastHit    hit;
        bool          foundGroundBelow = CastColliderDown(out hit, Mathf.Infinity);

        if (foundGroundBelow)
        {
            info.foundGround = true;
            info.normal      = hit.normal;
            info.distance    = hit.distance;
        }
        else
        {
            info.foundGround = false;
            info.normal      = Vector3.zero;
            info.distance    = Mathf.Infinity;
        }

        return(info);
    }