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 eshan-mathur · Jan 27, 2015 at 10:03 PM · physicsrigidbodymobileperformancetriggers

Detecting Input on ~100 Objects

Old Setup: 100ish objects with sphere colliders and non-kinematic rigidbodies that moved almost exclusively through physics interactions. New Setup: 100 odd objects that are moved through code (not physics) but need to all detect input from the user. These objects still move often. The 100ish objects in the old setup still exist and roughly inform the movement of the new 100 objects.

My old input code utilizes raycasting from a touchpoint through to an object's colliders. What's the most performant way to capture input on the new objects, instead of the old?

To be clear - the new 100 objects do not have a collider or rigidbody right now because they don't really need one. To avoid rewriting my input code, I'm considering attaching a kinematic rigid body and sphere collider to each of the new objects. The potential problem? Double the colliders and double the rigid bodies. Physics is already showing up as a hotspot in my mobile performance, I can't risk making this worse.

The question is, how much more of a hit am I going to take by creating 100 kinematic rigidbodies and colliders? I would imagine a kinematic rigidbody isn't even close to as expensive as a non kinematic rigidbody.

If it is expensive, what's my best method of detecting input on the new objects? Triggers? Kinematic rigidbody triggers? Some weird combination of something I haven't considered?

Remember, the old 100 objects that are rolling around the scene still need to exist and calculate.

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
0

Answer by LessThanEpic · Jan 27, 2015 at 11:02 PM

I use the MonoBehaviour.OnMouse---() functions (don't let the mouse part confuse you, they work on touch screens too). The performance on this has been pretty good, I'm guessing Unity does some optimizations behind the scenes that makes it faster than doing your own raycasting.

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 eshan-mathur · Jan 27, 2015 at 11:08 PM 0
Share

I read that having a collider but not a rigidbody marks that object as a static collider and is thus very expensive to move around. That's why I brought up kinematic rigid bodies. Can someone confirm that is true?

avatar image LessThanEpic · Jan 27, 2015 at 11:12 PM 0
Share

I stand corrected. Apparently the static collider thing is true.

http://answers.unity3d.com/questions/180210/unity-creating-static-colliders.html

I hadn't heard about that before.

avatar image
0

Answer by DanSuperGP · Jan 27, 2015 at 11:18 PM

You're going to want to use kinematic rigidbodies and colliders detecting raycasts. That's simply the best way to do it.

Comment
Add comment · Show 3 · 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 eshan-mathur · Jan 28, 2015 at 01:41 AM 0
Share

So adding 100 kinematic rigidbodies and 100 colliders on top of 100 rigidbodies and colliders isn't going to have a significant performance impact?

avatar image LessThanEpic · Jan 28, 2015 at 03:02 AM 0
Share

Only one way to find out.

avatar image DanSuperGP · Jan 28, 2015 at 06:00 PM 0
Share

Doubling the number of objects in your scene is going to have a performance impact...

You doubled the number of objects in your scene...

There's no way around that... it doesn't change the fact that the best way to do the kind of input you want to do is the way you already know.

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

21 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

Related Questions

Add 2d rigidbodies to moving objects to increase performance or not? 1 Answer

Are my kinematic rigidbodies slowing my scene down? 2 Answers

Raycaste vs trigger Colliders & Rigidbody performance 1 Answer

Is it possible to combine child trigger of a object to only trigger OnTriggerEnter once? 1 Answer

Is there any way to make convex meshes with size about 0.1 unit work correct? 0 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