Obstacle Avoidance

Matthew revcompgeek at gmail.com
Thu Jun 14 15:16:36 EDT 2007


I am trying to write a game, and I need some of the objects to avoid  
other objects. I didn't want to use a complicated pathfinder, so I am  
just using Obstacle Avoidance. I have a problem with my script so  
that if the moving object has to go around an obstacle and in doing  
so goes around the very top of the obstacle (they are all circles),  
it gets stuck. The problem is that it uses the angle to the  
destination and the angle to the center of the obstacle to compare,  
and sometimes one of the angles are > 270 and the other is < 90, and  
it goes the wrong direction. I have posted the stack and you can just  
throw this in the message box:

go stack URL "http://revcompgeek.googlepages.com/obstacleAvoidance.rev"

Just right click somewhere and the mover will try to go there.
The code that needs to be changed is in the mover graphic, on the  
line that says

if obstangle < tangle then

-- 
Matthew Peterson
Programmer
Christa McAuliffe Space Education Center





More information about the use-livecode mailing list