Skip to content

Instantly share code, notes, and snippets.

@DouglasUrner
Last active October 4, 2021 17:50
Show Gist options
  • Select an option

  • Save DouglasUrner/102bee59792e90606b031a95d189a19c to your computer and use it in GitHub Desktop.

Select an option

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.
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