Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 code-blep · May 11, 2013 at 06:59 PM · physicscollisions

Objects 'Clumping' problem

Hi,

I have a scenario where there are about 50 to 100 objects all following one target. All objects have rigid-bodies, non-trigger colliders, and using physics based movement.

After chasing their target for a while they end up being very close to each other and start to clump. As a result they all start bumping into each other. This starts to slow the game down, so I am guessing it's down to all the excess physics interaction going on between them.

So, I am looking for suggestions on the best route to avoid them 'clumping' together. Is there a traditional method dealing with this type of scenario etc?

Thanks!

Paul

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

1 Reply

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

Answer by Fattie · May 12, 2013 at 07:43 AM

This is a super-difficiult and super-cool problem.

Here's one quick solution that can sometimes help.

Your target is TT right.

Make an imaginary sphere around TT. Well .. imagine it :)

Take a number NN and a radius RR. You will tune these values later. At first try say "20" and "15 meters".

For NN times, make a new marker (I mean empty game object) called TT1, TT2 etc.

In fact position those randomly within a sphere of radius RR around TT.

Using gizmo or something add a dot for all these for your benefit. Note that as the spaceship at TT actually moves through space, all these "secondary targets" will follow - right? As the spaceship pitches, rolls and yaws this "cloud" of TTn will sort of swing around in space. OK?

Now regarding your 50-100 chasers.

In fact, don't make them chase TT. Make each one of them randomly choose one of the TTn, and chase that.

Again, test this over and over with different values of NN and RR. And instead of "a sphere" the random TTn points could be on (say) a halfsphere facing forward, or on a small plane normal to the forward of the TT-spaceship.

Further, you may want to randomly change the TTn ("every four seconds" or something) which each chaser is looking at, and further you may change to TT itself when within a certain distance, perhaps. (Naturally this depends entirely on what you're doing and why.)

I hope this approach helps. It is vastly easier if you post a screen shot to give an idea of the scales involved, etc.

Comment
Add comment · Show 10 · 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 code-blep · May 12, 2013 at 12:33 PM 0
Share

"This is a super-difficiult and super-cool problem" hehe yeah I always seem to end up with those! That's an interesting idea Fattie, I am considering using a flocking approach to controlling them, so for example find the nearest attacker to me and make it the flock lead. I think I will play with both today and see how it goes. If no-one else replies to this with other ideas, I'll mark it as an answer.

avatar image Fattie · May 12, 2013 at 03:16 PM 1
Share

another simple idea is this.

imagine you are Chase38. so "now" mark the point where the target is. call that currentTarget. Chase towards that currentTarget.

ie, the Spaceship will move on from currentTarget, but you chase to currentTarget.

Next, take a RANDO$$anonymous$$ time, between about 1 and 3 seconds.

after that random time, reset currentTarget to where the spaceship is now.

Now the key is, each of the 50 flock members do that individually, ie they all random choose, each time, the time I describe.

this is another very simple approach that can work. they will all have fun and move around, without just crashing together

avatar image whydoidoit · May 12, 2013 at 03:40 PM 1
Share

So particle and insect control systems often don't consider inter agent collision at all - which is one possibility. Another is to use a different method to keep them apart, turn off their inter-collision physics and ins$$anonymous$$d use something like writing position with some degree of rounding into a sparse dictionary - if you find something else already there, move the new item in the opposite direction to their current positions and keep doing that until it is in an unoccupied space. The trick then is to Lerp to this new position.

avatar image code-blep · May 13, 2013 at 08:58 PM 0
Share

Thanks guys! Loads to be going on with here. I am currently working my way through all my scripts so they use #pragma strict and variable caching, when I am done I will have a go.

avatar image Fattie · May 14, 2013 at 08:16 AM 0
Share

Funny how often in life we have to attend to extremely modest concerns before dealing with huge philosophical issues.

Show more comments

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.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Apply rigid body force in opposite direction of collider 1 Answer

Find all objects currently colliding with trigger 1 Answer

Static collider restitution 1 Answer

Physics2D bug or something I can avoid? 3 Answers

Clarification on updates, physics events order and frequency? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges