Can anyone tell me how to get a character to move to the right and left suddenly?
I used this before, but it doesn't work on Character Colliders(Makes them pass through the floor). The same thing happens when I use translate to move them, it doesn't take into account the collider.
//Moves right when z is pressed
if (Input.GetKey("z")){
transform.position -= Vector3.right * speed * 2* Time.deltaTime;
}
//Moves left when v is pressed
if (Input.GetKey("v")){
transform.position += Vector3.right * speed* 2 * Time.deltaTime;
}
Still not working with a rigidbody attached.
– PersonaWhat isn't working?
– IJMIt doesn't move at all when pressed.
– PersonaI think that thiw will hwlp you: http://unity3d.com/support/documentation/ScriptReference/Rigidbody-velocity.html Just for test, try setting a big velocity.
– IJMIt works but it won't stop moving now.
– Persona