예제 #1
0
    void Movement()
    {
        newTrans.transform.position    = mainCam.transform.position;
        newTrans.transform.rotation    = mainCam.transform.rotation;
        newTrans.transform.eulerAngles = new Vector3(0, newTrans.transform.rotation.eulerAngles.y, 0);
        float fall = rb.velocity.y;

        if (control.GetBtnPressed(1))
        {
            fall += jump;
        }
        rb.velocity = newTrans.transform.TransformDirection(control.MoveInput) * speed;
        rb.velocity = new Vector3(rb.velocity.x, fall, rb.velocity.z);
        if (control.MoveInput != Vector3.zero)
        {
            Vector3 tempVel = rb.velocity;
            tempVel.y = 0;
            //Use FaceTowardsMovement
            FaceTowardsDirection(tempVel);
        }
        if (control.GetBtnHeld(2))
        {
            rb.velocity = rb.velocity / 2;
        }



        anim.SetBool("Slowed", control.GetBtnHeld(2));
        anim.SetBool("Woo", control.GetBtnPressed(3));
        //FixStuckWall();

        anim.SetBool("Moving", control.MoveInput.magnitude > 0.1);
        //isGrounded = false;
        previousVel = rb.velocity;
    }
예제 #2
0
 IEnumerator PlayerLoop()
 {
     while (true)
     {
         InputRegister();
         GravityChange();
         Movement();
         FaceTarget(control.GetBtnPressed(3));
         if (control.GetBtnPressed(2))
         {
             anim.SetTrigger("Dodge");
             yield return(Dodge(newTrans.transform.TransformDirection(input)));
         }
         if (control.GetBtnPressed(1))
         {
             anim.SetTrigger("Atk1");
         }
         currentVelocity = rb.velocity;
         yield return(new WaitForEndOfFrame());
     }
 }