예제 #1
0
 // Start is called before the first frame update
 void Start()
 {
     camZoom     = cam.fieldOfView;
     body        = GetComponent <Rigidbody>();
     anim        = GetComponent <Animator>();
     wallJumpDir = jumpOffDirection.None;
 }
예제 #2
0
    private void determineWallRun(Collision collision) //Determines which direction the player will wallrun
    {
        //Get the normal vector, change player to have their side to the wall
        Vector3 wallForward = transform.TransformVector(collision.transform.forward);
        Vector3 playerRight = transform.TransformVector(transform.right);
        float   dot         = Vector3.Dot(playerRight.normalized, wallForward.normalized);

        if (dot > (1.0f / 4.0f) && dot <= 1) //Left side run
        {
            anim.SetBool("wallRunningR", true);
            wallJumpDir       = jumpOffDirection.Right;
            transform.forward = collision.transform.right * -1;
        }
        else if (dot < (-1.0f / 4.0f) && dot >= -1) //Right side run
        {
            anim.SetBool("wallRunningL", true);
            wallJumpDir       = jumpOffDirection.Left;
            transform.forward = collision.transform.right;
        }
        else //Running forward
        {
            wallJumpDir       = jumpOffDirection.Back;
            transform.forward = collision.transform.forward * -1;
        }
    }