- Home /
Character controller wont move
I have an NPC which has a character controller attacked to it. With a c# script I generated a random position (vector3) which the NPC should move to. But when I start the game, he just holds his place.
Random position(waypoint is the random vector3):
waypoint = new Vector3(startPos.x + Random.Range(-30, 30), startPos.y + Random.Range(-30, 30), startPos.z + Random.Range(-30, 30));
To move the NPC I've tried:
transform.parent.LookAt(new Vector3(waypoint.x, waypoint.z, waypoint.z));
controller.Move(transform.TransformDirection(0,0, 1));
But this doesn't work :/ Any idea's?
Answer by Mill0698 · Jul 16, 2013 at 03:58 AM
This might not help by try
movDir = transform.forward * movementSpeed;
controller.Move(movDir*Time.deltaTime);
His problem is that he's trying to pass 3 integers as the arguments for TransformDirection. Not a Vector3
Thanks for the reply, @Benproducts, yes i'm passing 3 integers, but I convert them to a vector3, so that woulnd hurt right?
@NickP No you are not converting them. Converting them would be writing Vector3(0, 0, 1)
(aka Vector3.forward
), not just (0, 0, 1)
. Do you get any errors?