I’m following a tutorial on youtube from 2011, so I’m guessing this has been changed in some way. I have already tried googleing the issue, but nothing helps.
PlayerMovementScript.js:
I would guess that the Horizontal and Vertical inputs should be set to something…? I just reset all of the Inputs in Project Settings, but it didn’t help.
Use Debug.Log to see the values returned by Input.GetAxis to see if you’re getting the input you want.
If that works fine then put dummy values instead of them in the AddRelativeForce function to see if something happens.
If still nothing happens then you messed something up with the Rigidbody.
Nothing happens when I Debug ether. I am however being spammed with this error:
NullReferenceException: Object reference not set to an instance of an object
PlayerMovementScript.Update () (at Assets/Scripts/JavaScript/PlayerMovementScript.js:18)
I changed all of the “GetComponent.()” to “GetComponent(Rigidbody)” but it still does not work.
I’m still getting the error on line 18 as well. Don’t now whats that all about.
that’s valid unityscript for a typed getcomponent (and yes it looks weird to c# eyes ).
I would suggest you find a better tutorial. You really shouldn’t be using GetComponent in Update to find and access components on the current gameobject that do not change between frames.
Have you looked at the tutorials in the learn section? if you’re looking to work on a “moving through rigidbody and forces” approach have a look at the rollaball tutorial.