Ejemplo n.º 1
0
 void Movement()
 {
     //float horizontal = Input.GetAxis("Horizontal");
     CheckGrounded();
     velocityX = rigidBody.velocity.x;
     if (blink.IsBlinking())
     {
         velocityX = 0;
     }
     else if (hotkeys.IsRightPressed())
     {
         velocityX = speed;
     }
     else if (hotkeys.IsLeftPressed())
     {
         velocityX = -speed;
     }
     else
     {
         velocityX = 0f;
     }
     if (ChangesDirection())
     {
         movingPlayer.Flip();
     }
     if (jumped == true)
     {
         rigidBody.AddForce(jumpVector);
         jumped = false;
     }
     rigidBody.velocity = new Vector2(velocityX, rigidBody.velocity.y);
     //rigidBody.velocity = new Vector2(velocityX * speed, rigidBody.velocity.y);
 }
Ejemplo n.º 2
0
 void Update()
 {
     if ((hotkeys.IsLeftPress() != hotkeys.IsRightPress()) && walkAudio.enabled)
     {
         walkAudio.Play();
     }
     if ((!hotkeys.IsLeftPressed() && !hotkeys.IsRightPressed()) || !playerMovement.IsGrounded())
     {
         walkAudio.Stop();
     }
     if (playerMovement.JustLanded() && (playerMovement.GetVelocityX() != 0f) && walkAudio.enabled)
     {
         walkAudio.Play();
     }
 }