Hello there. I am new and just starting Unity. I am taking the code from part two of the course by I seem to have ran into an error I cannot decipher. The problem is “float”. Apparently it is an unexpected symbol. Why it is puzzles me.
using UnityEngine;
using System.Collections;
public class PlayerController:MonoBehaviour
{
public float speed;
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis (“Horizontal”) float moveVertical = Input.GetAxis (“Vertical”)
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical)
Uhm, I seem to have encountered another problem after adding the semicolons.
“Assets/Roller/Scripts/PlayerControler.cs(14,43): error CS0120: An object reference is required to access non-static member `UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3, UnityEngine.ForceMode)'”
You wrote ‘Rigidbody’ instead of ‘rigidbody’.
The first one is the name of the class. What you wanna use in this case is the second one. It references an instance of the Rigidbody class if there is a Rigidbody attached to the gameObject. If not, it will be ‘null’', the literal for reference types witch basically means ‘i do not reference any instance of this class’.
Ah. I can’t believe I thought it would work with a capital.
Forgive me, I have a terrible habit of using capitals. Thank you so much for the information! I’m beginning to see what I need here and there.
“The referenced script on this Behaviour is missing!”
Anyone know why? I’ve looked up and at most I’ve found a few solutions involving loading an empty scene and bringing everything in, or using a “FindMissingScripts” script.