I wrote the following script:
As you can see, a basic script which ought to move the object i dropped it on when i press the WASD keys. However, putting it on my object, it doesnt work. Am i doing anything obviously wrong or anything?
My object is a combo plane/BoxCollider with the plane rotated 90 degrees (to face my camera, the Z axis points down now), and it is constrained to 2 dimensions (X and Y).
asked Mar 28 '10 at 09:26 PM
The main problem is that there are no keys called "W", "S" etc.; you should get an error message if you try to use those. The actual names are lowercase ("w", "s", etc.) But instead of hard-coding input (people don't necessarily have QWERTY keyboards), use Input.GetAxis. Also it's better not to hard-code the force since you might need to change that. Using Update without Time.deltaTime will make your code framerate-dependent, but physics should be in FixedUpdate anyway.
answered Mar 28 '10 at 10:23 PM