Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by baal32 · Apr 19, 2016 at 06:27 AM · 2d gamerigidbody2dphysics2dcollider2d

Do I need Rigid2DBody if I don't plan to use physics?

Disclaimer - I'm completely new to Unity - went through the basic 2D tutorial and have read topics on these forums and in docs but that's about it.

I'm working on a simple ant colony simulation (a toy ant colony optimization algorithm) with a small fixed game board, food and obstacles placed randomly, and the ants controlled completely by the algorithms (no player controls). I don't plan to use any physics at all but I do want the ants to stay within the board and they need to be aware of when they 'collide' with obstacles or food (note that I don't want them bouncing off the obstacles and I might want them to actually sit directly on top of the food sprites). I'm also planning on moving the ants using their position instead of applying 2d forces (is that a bad idea?)

Do I use a 2D Rigid Body and colliders on the ants, food, obstacles, and 4 rectangles bounding the game board sprite? And then I set everything to Is Kinematic = true to prevent physics and use triggers?

Extra question - does it make sense to have an otherwise empty game object 'GameController' with the only component a script that produces ants, randomly places food and obstacles? (From my reading it seems like that's how it's done but want to make sure)

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

Answer by thereisnotrying · Apr 19, 2016 at 08:11 AM

If you want to use the triggers to detect if an ant sits on top of the food than you need rigidbodies. Regarding movement i would suggest applying forces. You can searchengine things like how to move towards a point.

GameController makes perfect sense.

Comment
Add comment · 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
1

Answer by Immanuel-Scholz · Apr 19, 2016 at 08:20 AM

Using a kinematic Rigidbody together with triggers is a very sensible way of scripting. A lot of games do not utilize non-trigger colliders - there is nothing wrong with that. Also, moving rigidbodies via transform.position (and not via the rigidbody) works fine.

If you only occasionally need to test for overlapping of objects, you can also use all the Physics2D.Overlap* functions and don't need any rigidbodies at all (be sure to check "Queries Hit Triggers" in Physics2D settings of your project or else the trigger areas will not be returned).

As for the second question: Yes, it is totally normal and very common to use GameController - like objects with only few or one component and where the transform position is irrelevant. Even the build-in systems in Unity use this technique, i.e. if you create any UI component, Unity will automatically add an "EventSystem" game object which is some kind of controller-object for all your UI events..

Comment
Add comment · 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

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

60 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 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 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 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

Had to turn off gravity scale, but now player goes through walls 0 Answers

All colliders not longer working 0 Answers

A box collider 2D (Is Trigger marked) stops my player from moving which has rigidbody 2D 1 Answer

How to prevent a 2D Kinematic asset passing through a 2D Box Collider. 1 Answer

2D Physics not working correctly 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