c# - Error: an object reference is required to access non static member -


using unityengine; using system.collections;  public class playermovement : monobehaviour {     public float movespeed;      private vector3 input;      void update () {         input = new vector3(input.getaxis ("horizontal"), 0, input.getaxis ("vertical"));         rigidbody.addforce(input * movespeed);     } } 

as of unity 5 unityengine.component.rigibody has been deprecated , using cause compiler error. instead need use getcomponent<rigidbody>(). in case, code looks like:

using unityengine; using system.collections;  public class playermovement : monobehaviour { public float movespeed;  private vector3 input;      void update ()      {         input = new vector3(input.getaxis ("horizontal"), 0, input.getaxis ("vertical"));         getcomponent<rigidbody>().addforce(input * movespeed);     } } 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -