• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Wes 1 · Jan 27, 2011 at 08:01 PM · enemycircle

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by AVividLight · Jan 27, 2011 at 08:06 PM

You could make the waypoints a little bigger...

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Wes 1 · Jan 27, 2011 at 08:16 PM 0
Share

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.

avatar image AVividLight · Jan 27, 2011 at 08:47 PM 0
Share

Yeah, I'm glad I could help... If I come across another answer, I'll let you know.

avatar image DaveA · Jan 27, 2011 at 10:17 PM 0
Share

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'

avatar image Wes 1 · Jan 27, 2011 at 11:11 PM 0
Share

@ Dave, gotcha, thanks allot for the input.

avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Wes 1 · Jan 27, 2011 at 11:25 PM 0
Share

GBStudios already gave the answer I was looking for, thanks though :)

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Enemy's wont die if spawned 1 Answer

Stopping AI's animation and movement 0 Answers

Urgent Enemy AI required for non profit project. 0 Answers

AI Enemy script 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges