Hey, I have a model i made in 3DS, and put my movement script to it.
Everything is fine except when I move forward it moves along the models local Z axis instead of the X.
Any ideas of how to amend?
Can you show us the script?
transform.forward is z axis movement, is that what you’re using?
Yeah this is it:
var speed = 3.0;
var rotateSpeed = 3.0;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
// Rotates around the Y axis
transform.Rotate(0, Input.GetAxis (“Horizontal”) * rotateSpeed, 0);
// Forwards and backwards
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis (“Vertical”);
controller.SimpleMove(forward * curSpeed);
}
Is it a 2D-type game? use Vector3.right and -Vector3.right to move left and right across the screen. the only way forward would work is if you used transform.forward (transform is your local object) and it was rotated so that the z axis faced in the direction you wanted to move. Vector3 is world orientation.
well the game is a 3rd person game, but the guy strafes left when I push forward
Just use -Vector3.right then.
ok, where would that go?
I suppose it’s a bug. I’m using Unity 3.4 and have the same issue with this script.
When I try to move forward player moves forward+left. When I try to move back - it moves fine.