Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2021
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerController : MonoBehaviour
  6. {
  7. private Rigidbody playerRb;
  8. private GameObject focalPoint;
  9. public float speed = 5.0f;
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. playerRb = GetComponent<Rigidbody>();
  14. focalPoint = GameObject.Find("Focal Point");
  15. }
  16.  
  17. // Update is called once per frame
  18. void Update()
  19. {
  20. float forwardInput = Input.GetAxis("Vertical");
  21. playerRb.AddForce(focalPoint.transform.forward * speed * forwardInput);
  22. }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement