Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Update()
- {
- targetVelocity = new Vector2(Input.GetAxis("Horizontal") * maxSpeed, 0);
- if (Input.GetButtonDown("Jump") && grounded)
- {
- velocity.y = jumpPower;
- }
- //flip the player if moving left or right
- if(targetVelocity.x < -.01)
- {
- transform.localScale = new Vector2(-1, 1);
- }
- else if(targetVelocity.x > .01)
- {
- transform.localScale = new Vector2(1, 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement