Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerController : MonoBehaviour
- {
- private Rigidbody playerRb;
- private GameObject focalPoint;
- public float speed = 5.0f;
- // Start is called before the first frame update
- void Start()
- {
- playerRb = GetComponent<Rigidbody>();
- focalPoint = GameObject.Find("Focal Point");
- }
- // Update is called once per frame
- void Update()
- {
- float forwardInput = Input.GetAxis("Vertical");
- playerRb.AddForce(focalPoint.transform.forward * speed * forwardInput);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement