Advertisement
Guest User

Untitled

a guest
May 27th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public class Movement : MonoBehaviour
  7. {
  8. //Movement Variables
  9. public float Movespeed = 5f;
  10.  
  11. public Rigidbody2D rb;
  12.  
  13. public Animator Anim;
  14.  
  15. // GetAxisRaw
  16. Vector2 movement;
  17.  
  18. //Jump
  19. public bool Ifjumping;
  20.  
  21. void Update()
  22. {
  23. //Input
  24. movement.x = Input.GetAxisRaw("Horizontal");
  25. movement.y = Input.GetAxisRaw("Vertical");
  26.  
  27. //Jump
  28.  
  29. if (Input.GetKeyDown(KeyCode.Space))
  30. {
  31. Ifjumping = true;
  32.  
  33. }
  34.  
  35. }
  36.  
  37. void FixedUpdate()
  38. {
  39. rb.MovePosition(rb.position + movement * Movespeed * Time.fixedDeltaTime);
  40.  
  41. if(Ifjumping == true)
  42. {
  43. Anim.Play("Jump");
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement