Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerMovement : MonoBehaviour
  6. {
  7. private Rigidbody2D rgdbdy2d;
  8.  
  9. public float speed;
  10.  
  11. private void Start()
  12. {
  13. rgdbdy2d = GetComponent<Rigidbody2D> ();
  14. }
  15.  
  16. private void Update()
  17. {
  18.  
  19.  
  20. }
  21.  
  22. private void FixedUpdate()
  23. {
  24.  
  25. // float moveHor = Input.GetAxis("Horizontal");
  26. // float moveVer = Input.GetAxis("Vertical");
  27. // Vector2 mvmnt = new Vector2(moveHor, moveVer);
  28. // rgdbdy2d.AddForce(mvmnt * speed);
  29.  
  30. float moveHor = Input.GetAxisRaw("Horizontal")*speed;
  31. float moveVer = Input.GetAxisRaw("Vertical") * speed;
  32. Vector2 mvnmt = new Vector2(moveHor, moveVer);
  33. rgdbdy2d.velocity = mvnmt;
  34. rgdbdy2d.freezeRotation = true;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement