- Home /
Question by
Linkthehylian04 · Jun 19, 2017 at 01:45 PM ·
scripting problemc #
Why doesn't this script work?
Here is my script: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerController: MonoBehaviour
{
private Rigidbody;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.velocity = movement;
}
}
for some reason, it says the semicolon after private rigidbody isn't suppose to be there. Can someone please help? This script is in c#.
Comment
Best Answer
Answer by Jessespike · Jun 19, 2017 at 01:59 PM
rb is not defined anywhere.
you probably meant to do this:
private Rigidbody rb;