Beispiel #1
0
    private void LookForStepLedges(PlayerController player)
    {
        if (Input.GetButtonDown("Jump") && !isRootMotion)
        {
            isRootMotion = ledgeDetector.FindPlatformInfront(player.transform.position,
                                                             player.transform.forward, 2f, out ledgeInfo);

            if (isRootMotion)
            {
                float height = ledgeInfo.Point.y - player.transform.position.y;

                // step can be runned over
                if (height < player.CharControl.stepOffset)
                {
                    isRootMotion = false;
                    return;
                }
                else
                {
                    player.transform.rotation = Quaternion.LookRotation(ledgeInfo.Direction, Vector3.up);
                    player.DisableCharControl(); // stops char controller collisions
                }

                if (height <= 0.9f)
                {
                    player.Anim.SetTrigger("StepUpQtr");
                }
                else if (height <= 1.5f)
                {
                    player.Anim.SetTrigger("StepUpHlf");
                }
                else
                {
                    player.Anim.SetTrigger("StepUpFull");
                }

                waitingBool = true;
            }
        }
    }
Beispiel #2
0
    private void LookForStepLedges(PlayerController player)
    {
        if (Input.GetKeyDown(player.Inputf.jump) && !isRootMotion)
        {
            isRootMotion = ledgeDetector.FindPlatformInfront(player.transform.position,
                                                             player.transform.forward, 2f, out ledgeInfo);

            if (isRootMotion)
            {
                float height = ledgeInfo.Point.y - player.transform.position.y;

                // Step can be runned over
                if (height < player.CharControl.stepOffset)
                {
                    isRootMotion = false;
                    return;
                }

                player.DisableCharControl();  // Stops char controller collisions
                player.UseRootMotion = false;

                if (height <= 1.1f)
                {
                    player.Anim.SetTrigger("StepUpQtr");
                }
                else if (height <= 1.5f)
                {
                    player.Anim.SetTrigger("StepUpHlf");
                }
                else
                {
                    player.Anim.SetTrigger("StepUpFull");
                }

                waitingBool = true;
            }
        }
    }