|
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).
(comments are locked)
|
|
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. +1 100% right :) I'll just delete my answer..
Mar 28 '10 at 10:33 PM
Lipis
You both provide nice answers but i think this one fits better as it both fixes my problem and points out how i could do things better! thanks!
Mar 28 '10 at 10:35 PM
RCIX
(comments are locked)
|
