Here goes a rally stupid question, but I’ve tried everything I could thing of and everything I’ve read on here, and nothing works.
I’m currently doing the ‘Roll a Ball’ tutorial and I’m onto the 2nd video, around 9:30 in.
Despite typing word for word what the tutorial says, and after fixing it with the help from other questions, I still get this error:
"Assets/Scripts/playerController.cs(13,35): error CS0120: An object reference is required to access non-static member `UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3, UnityEngine.ForceMode)’ "
It’s driving me crazy… I’ve corrected all the spelling mistakes I could see and read about on here. Typing rigidbody in lowercase made the error stop. But I can’t move the ball.
Heres my code:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
Rigidbody.AddForce(movement);
}
}
The tutorial is outdated, so you need to save the Unity Mono-develop, then close it.
Return to unity, in the Assets options drop-down box (up the top, near File, Edit etc.), click Run API Updater…. It will recommend that you make an backup, up to you whether or not you do.
This should fix your problem.
If your using unity 4 or later, then I can’t help you sorry.
}
my code is this.
and problem is :Cleaning up leaked objects in scene since no game object, component or manager is referencing them
MonoScript has been leaked 1 times.