- Home /
Help with Patrol Script!!
I have a enemy, that has a waypoint walking system, and i want it to patroll at each way point stop.
So i have some flags, that tells if hes walking or patrolling. If he's walking it will call the walkingscript, otherwise it will call the patroll script. I have a problem with de patrol script.
I want the patrol script to turn my robot to his right, around 90 degrees and then turn around 90 degrees do his left, all from the start position he was facing.
Any ideas of how to make this work?
function PatrolAtStop(position, angle)
{ lastRotation = position.forward;
if (angle < 60) {
transform.Rotate(0,Time.deltaTime * 20, 0);
anglePatrolled = Vector3.Angle(lastRotation, transform.forward);
}
if (angle >= 60)
{
patrolling = false;
anglePatrolled = 0;
}
}
Its not working
Answer by Alexey Elyakov · Sep 21, 2010 at 11:17 PM
You can use state machine for this.
I already have that, with some boolean flags. i need help with the rotating script!
As told my geometry $$anonymous$$cher, if problem not solves, make larger drawing. I$$anonymous$$HO, best way is make more clear state machine WITH SUBSTATES and for each state/substate make separate function, describing actions. After this i think everything will fall into place. Designing behaviour of you robot brings more fun, than complete script.
And sorry my English.