hi every one i do not understand what is wrong with my script as it is exactly the same as unity's tutorial's one plz help: Assets/scripts/PlayerMovement.cs(13,27): error CS0120: An object reference is required to access non-static member `UnityEngine.Rigidbody.AddForce(UnityEngine.Vector3, UnityEngine.ForceMode)' thanks Evenus1
here is my script: using UnityEngine; using System.Collections; public class PlayerMovement : MonoBehaviour { void FixedUpdate() { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical=Input.GetAxis("Vertical"); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); Rigidbody.AddForce(movement); } } could u plz tell me which bit to change
You need to store a reference to the rigid body , or the game object its on (and then use get component). Like the example in the docs http://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html
this is still very confusing. and i have followed a tutorial that i watched work made by unity so why is it not right.
Just adjust your code to reference the rigid body on the object, as demonstrated in the example I linked.
Again with this.... Your code does not match the tutorial - http://forum.unity3d.com/threads/help-with-c-scripting-very-simple.313588/#post-2039828