- Home /
How to do simple player movement?
I'm having trouble creating a simple player object and getting it to move in response to the keyboard in Unity. The player object has a Character Controller component attached. I haven't changed any of the settings on that component, nor have I changed any of the Input Manager settings. So, is it enough to just create an object (in this case, a simple cube for now) and attach a Character Controller component? Or, is there some other step that I'm missing? I'm assuming I shouldn't have to write any scripts for standard behavior like this. Thank you.
If you have a player move script attached to your game object, and you believe that the code is in fact correct, think about going to Edit->Project Settings->Input . This brings up a list of keys that you can set in the inspector.
Why wouldn't you have to write scripts? What makes it standard behaviour? If the input came from a joystick or a 360 controller or a wii or a touch interface or the keyboard or the mouse, would the game know what to do with each input? If someone wants to change the controls or what they do? Standard behaviour is that the interface has to be coded/scripted at some point and since most engines are usually designed to make as many varieties of game as possible, they leave that to the game dev. to do during development.
Answer by skovacs1 · Aug 27, 2010 at 01:05 AM
You added a character controller. Did you notice that it was listed under physics components? What makes you think that adding a physics component will suddenly take care of input, etc.?
You need to add a script to deal with input. You don't even need a character controller if you aren't going to use its OnControllerColliderHit function or any of its specific variables.
Try one of the tutorials - you would have found your answer within a few minutes if you had. I recommend the FPS tutorial, the 2D platformer and 3D gameplay tutorials. This question seems like you didn't even read any of the documentation before you came here asking questions.
Answer by Adam Rademacher · Oct 03, 2010 at 11:34 PM
In the standard assets included with your unity download, you should find several scripts you can use for player movement 'right out of the box.' Like Scovacs1 posted earlier, it's highly recommended to start out with the tutorials available to get a good feel for Unity.