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
2
Question by Thet Naing Swe · Dec 07, 2010 at 08:53 AM · collisiondetectionefficiencysteeringavoid

the most efficient way to detect colision between objects in a large scene (Strategy Game)

What's the most efficient way to detect collision between objects. What kind of strategy used to detect the collision between objects in a very large scene like strategy games. I know that I can't use Rigid body for each objects in the scene as physics are quite expensive and not suitable for mobile devices. I saw some tower defense games with more than 50 moving characters in the scenes and also loads of tower shooting them in a very good framerate on iPhone 3G...

How about AI Character avoiding each others? What's gonna be the most efficient way to make sure that the objects are not colliding each other? Does Physics.RayCast() is efficient or distance checking method? Does the steering behaviors used lots of calculations?

Comment
Add comment · Show 1
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 Proclyon · Dec 07, 2010 at 09:02 AM 0
Share

Can your characters move in UP/RIGHT/LEFT/DOWN or 360 degrees? If the first is true I would think you could build something with raycasts since it's just a few of them anyway and not a huge distance.

1 Reply

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

Answer by Anton Petrov · Dec 07, 2010 at 04:26 PM

IMHO, you should approximate all your objects with bounding circles on a 2D plane (ground). I think this is what every one do in their RTS games (like StarCraft :) ) where there are a lot of small units.

Collision tests between 2D circles are very fast. It looks like this (pseudocode!!!):

    bool collided = ( Distance( circle1.position, circle2.position ) <= 
(circle1.radius + circle2.radius) );

NOTE: Finding distance usually requires Sqrt() which is slow. So it is a good idea to compare squared distance and squared sum of radiuses.

Then you will need some optimizations because you won't like to do tests for each pair of your 50 moving units every frame (I guess it is something like 2,450 tests). The purpose of optimization is to find pairs which most likely collide or to reject those which definitely won't collide.

If you have some sort of space partitioning structures like Quad tree in your game, then it can be handy.

Very simple approach (I invented it just now :) ) is the following:

Let's assume that RMax is a maximal radius of the bounding circle of your in-game unit. Then you can represent your level as a grid of square cells with a cell size of RMax. When your units move you easily define in which cells their centers lie. And knowing that you can test only those pairs of objects which lie in adjacent squares. That's it!

Comment
Add comment · Show 2 · 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 Thet Naing Swe · Dec 08, 2010 at 01:36 AM 0
Share

Thanks.... this is what require to know.. I am really keen of making Strategy for mobile devices now... especially for iPad...

avatar image cregox · Sep 27, 2011 at 06:42 PM 0
Share

isn't this the same as using sphere colliders?

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

1 Person is following this question.

avatar image

Related Questions

Destorying an object when it hits the ground 1 Answer

How do I allow an object pass through a wall/object of the same colour/material? 2 Answers

Collision Checking 1 Answer

Make invisible wall appear visible upon collision/detection 1 Answer

Object detection 2 Answers


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