karen_constantine

Untitled

Apr 10th, 2023
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerController : MonoBehaviour
  6. {
  7. public float speed;
  8.  
  9. private Rigidbody rb;
  10.  
  11. void Start()
  12. {
  13. rb = GetComponent<Rigidbody>();
  14. }
  15.  
  16. void FixedUpdate()
  17. {
  18. float moveHorizontal = Input.GetAxis("Horizontal");
  19. float moveVertical = Input.GetAxis("Vertical");
  20.  
  21. Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
  22.  
  23. rb.AddForce(movement * speed);
  24. }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment