- Home /
Why are these enemies circling waypoints?
My enemies will sometimes do what their supposed to, fly to one waypoint, then, once close enough, fly to the next. But sometimes, and I cant for the life of me figure out why, they start circling a waypoint. It doesn't seam to be a specific one. Here's what I use in my script:
function movewaypoint1 () {
var rotate = Quaternion.LookRotation(point1.transform.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotate,damp * Time.deltaTime); }
the best thing I can guess is that sometimes they get thrown off track, and then they start circling it and they don't get close enough to trigger moving to the next one. But I'm not sure how to fix it.
Answer by AVividLight · Jan 27, 2011 at 08:06 PM
You could make the waypoints a little bigger...
That seamed to work, which is a bit a frustrating because it seams like it should work regardless, AND I already increased the size from 1 to 5, this time I just made it 5 to 10. Thanks allot, I appreciate it.
Yeah, I'm glad I could help... If I come across another answer, I'll let you know.
Had same problem. If slerp under or overshoots by a little, it will circle back. It needs to have enough 'slack' to say 'close enough, now let's move on'
Answer by Jason B · Jan 27, 2011 at 11:11 PM
Sorry if I misunderstand, but could it be possible that your rotation isn't happening fast enough? I wonder if maybe you should increase the speed of your Quaternion.Slerp depending on how close to the way point you are, that way when you get really close to it, you'll be rotating extremely fast, avoiding just doing lazy donuts around it.
If you think about it, it kind of makes sense. If you turn the wheel of your car and hold it there in that exact spot (keeping your turn speed static throughout), and you try to drive onto a small circle on the ground by turning around to it, it will be impossible because even as you get closer, you're not taking tighter turns to zero in on your target.
GBStudios already gave the answer I was looking for, thanks though :)
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Enemy respawning after death 1 Answer
Move Objects arranged in Circle Forward 1 Answer
How to make basic AI in a 2d game? 4 Answers
Unity 3D Audio Clip Disabled 1 Answer