void Update() { if (onGround) { PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, NO_VELOCITY); PlayerUtility.ChangeAnimation(animator, RUNNING_ANIMATION); } // if (this.gameObject.transform.position.x >= FINISH_LOCATION_X_AXIS) { // PlayerUtility.PlayerAction(body2D, NO_VELOCITY, NO_VELOCITY); // PlayerUtility.ChangeAnimation(animator, IDLE_ANIMATION); // } }
void Update() { if (onGround) { PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, NO_VELOCITY); PlayerUtility.ChangeAnimation(animator, RUNNING_ANIMATION); } if (PlayerUtility.CanJump(onGround, Input.GetKey(SPACE))) { PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, JUMPING_VELOCITY); body2D.AddForce((Vector2.right * RUNNING_VELOCITY) * THRUST); } if (player.transform.position.x >= FINISH_LOCATION_X_AXIS) { PlayerUtility.PlayerAction(body2D, NO_VELOCITY, NO_VELOCITY); PlayerUtility.ChangeAnimation(animator, IDLE_ANIMATION); txt.text = LEVEL_COMPLETE_MESSAGE; } }
private void OnCollisionExit2D(Collision2D collision) { onGround = false; PlayerUtility.ChangeAnimation(animator, JUMPING_ANIMATION); }