Before updating to Windows 10 you may need to return your Pro license. More information here

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

more ▼

asked Sep 21, 2010 at 11:04 PM

avatar image

48 16 12 16

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You can use state machine for this.

more ▼

answered Sep 21, 2010 at 11:17 PM

avatar image

Alexey Elyakov
23 15 11 18

I already have that, with some boolean flags. i need help with the rotating script!

Sep 21, 2010 at 11:47 PM gilson

As told my geometry teacher, if problem not solves, make larger drawing. IMHO, 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.

Sep 22, 2010 at 02:06 AM Alexey Elyakov
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Sep 21, 2010 at 11:04 PM

Seen: 2187 times

Last Updated: May 06, 2011 at 11:18 AM