I am beginning to complete the programming and I'm trying my hand at Unity 5, but I get this error code I try to make this code
using UnityGen; Using System.Collections; Public Class Player Controller: Monobahaveer {Fixed Update (zero) (float hill horizontal = input. Gateexes ("horizontal"); float moveVertical = Input.GetAxis ("workspace"); Vector 3 movement = new vector 3 (HillHorouzontal, 0.0F ;);}}
An object reference to "cs0120 error" is necessary for nonstatic field method or property "Someone help me with this one
Thx!
Prior to Unity 5, there was a property of "rigidBody"
gameObject.rigidBody.AddForce ( Movement);
Because rigidBody
is not a property or monobihyar
, gameObject
. Unity is not 5, so you will need to use GetComponent
:
RigidBody RB = GetComponent & lt; RigidBody & gt; (); Rb.AddForce (movement);
See the documentation for more:
When all said and done, the code would be:
zero static update ( ) {Float triangle = input. Getexis ("horizontal"); Float moveVertical = Input.GetAxis ("workspace"); Vector 3 movement = new vector 3 (Hillhoroscotal, 0.0 f, movual); RigidBody RB = GetComponent & lt; RigidBody & gt; (); Rb.AddForce (movement); }
No comments:
Post a Comment