Last active
October 4, 2021 17:50
-
-
Save DouglasUrner/102bee59792e90606b031a95d189a19c to your computer and use it in GitHub Desktop.
Unity PlayerController script with a number of syntax errors for debugging / error message reading practice. To use copy the code and paste it into a new script in your Unity project called PlayerControllerXXX.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| public class PlayerController : MonoBehaviour | |
| { | |
| public float speed = 25; // Meters/second | |
| // Start is called before the first frame update | |
| void Start() | |
| { } | |
| public float turnRate = 30; // Degrees/second | |
| // Update is called once per frame | |
| void Update() | |
| { | |
| var verticalInput = Input.GetAxis("Vertical"); | |
| var horizontalInput = Input.GetAxis("horizontal"); | |
| transform.Translate(verticallnput * speed * Time.deltaTime * Vector3.forward); | |
| } | |
| transform.Rotate(Vector3.up, horizontalInput* turnRate * Time.deltatime); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment