- Home /
problem with character motion and movement
I have a problem with my characters. I find it hard to create its motion and movements. Can you suggest some ideas that can help me do it better or where can I get characters that aready has basic movements like running and walki for free
Yeah, like the standard assets? Just look around, it's not that hard.
Answer by aldonaletto · Nov 06, 2011 at 04:34 PM
Usually using CharacterControllers is the best thing to do. You can start with the CharacterController.Move example of movement script - it's easy to understand and modify. Just to have an idea, the script below is the example script with run and mouse control to turn left/right:
var walkSpeed : float = 6.0; var runSpeed : float = 9.0; var turnSpeed : float = 90; // speed to turn left/right
var jumpSpeed : float = 8.0; var gravity : float = 10.0;
private var moveDirection : Vector3 = Vector3.zero; private var angles : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
// turn left/right (around Y) with mouse X
angles.y = (angles.y + Input.GetAxis("Mouse X")*turnSpeed*Time.deltaTime) % 360;
transform.localEulerAngles = angles;
if (controller.isGrounded) {
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
// define speed
var speed = walkSpeed; // assume walkSpeed, but if shift pressed...
if (Input.GetKey("left shift")) speed = runSpeed; // change to runSpeed
moveDirection *= speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
what i mean here is the animation itself but thanks for the codes
You should post another question with a title like "How to add animations to my character?" - I know too little about animations to tell you something useful.
Your answer

Follow this Question
Related Questions
animation in blender to unity 0 Answers
character movement script 1 Answer
Hungry Shark Evolution Movement 0 Answers
Strange Character Movement (Mecanim) 0 Answers
hypercube animation 2 Answers