- Home /
Whats the script for basic Character movement?
I've had Unity for just over a month now, I pretty much know all about importing objects, the problems that have arose are the programming. If any of you would care to help me with the code for basic movements such as:
-Strafe Forward -Strafe Right -Strafe Left -Strafe Backwards -Jump
I'm not looking for complicated codes, All I really need is the script to for those basic movements.
(I tried looking up the codes, but when I attached the scripts to my object, it sayed that there were compiler errors with my script.)
You say all you really need is the script for those basic movements, but it's so not. You'll have to write a lot more scripts to complete any game, and even if you are starting with pre-written scripts you have understand what every word of them means if you want to connect them to anything else, or you'll keep getting compiler errors that you don't understand.
Answer by coastwise · Nov 02, 2012 at 02:44 PM
Have you tried the Character Controller included with Standart Assets? In Unity, click the Assets menu, Import Package > Character Controller.
Answer by CraftWitMe · Dec 02, 2012 at 10:27 PM
var speed = 3.0;
var rotateSpeed = 3.0;
function Update ()
{ var controller : CharacterController = GetComponent(CharacterController); //Rotate around y - axis transform.Rotate(0, Input.GetAxis ("Horizontal") rotateSpeed, 0); //Move forward / backward var forward = transform.TransformDirection(Vector3.forward); var curSpeed = speed Input.GetAxis ("Vertical"); controller.SimpleMove(forward * curSpeed); }
@script RequireComponent(CharacterController)