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 Rei · Apr 11, 2011 at 09:09 AM · ontriggeroncollision

Performance difference between OnCollision and OnTrigger messages?

How much real difference is there?

The unity reference says "leave out the collisionInfo parameter as this avoids unneccessary calculations", but what does it really mean by collisionInfo parameter? http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html

I am assuming if I don't access the contactPionts and relativeVelocity properties of the Collision class there's not much of a difference? (as each of them are going to be a function call that cost some heavy calculation...)

Am I getting this right?

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
4
Best Answer

Answer by Skjalg · Apr 11, 2011 at 09:13 AM

It is referring to the fact that you can create two kinds of OnCollisionEnters in your MonoBehaviour. The Costly One:

void OnCollisionEnter(Collision collision) 
{
  Debug.Log("Collided!");
}

... And the Low Performance:

void OnCollisionEnter() 
{
  Debug.Log("Collided!");
}

The second one is low performance, because the Unity3d engine doesn't need to do a lot of calculations for you in order to provide the Collision parameter :)

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 Rei · Apr 14, 2011 at 09:21 AM 0
Share

Thank you very much for helping!! I didn't know that you could omit the entire parameter. O.o||

But does that mean once the collision parameter is included, everything must be calculated and at maximum cost? Even though all I need is just the collision.gameObject.name...

Because that's 99% what I need to know, the object that is colliding with....

avatar image Skjalg · Apr 15, 2011 at 08:52 AM 0
Share

Unfortunately yes :(

avatar image burtonposey · Nov 05, 2012 at 12:50 PM 0
Share

I know this is an older thread but I wanted to add you can do a lot for performance by isolating the layers of objects that will collide by setting up those relationships in the Edit->Project Settings->Physics menu. This will $$anonymous$$imize the noise you're getting if you're only really looking for specific physics collisions.

avatar image
0

Answer by benjaminw · Jul 04, 2013 at 10:08 PM

If all you need to know is what the other object was you can make one or both of them Triggers and use OnTriggerEnter(Collider). You can use the Collider to get at the game object that's doing the colliding with the trigger.

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

2 People are following this question.

avatar image avatar image

Related Questions

OnTrigger, OnCollison 1 Answer

OnTrigger & OnCollision not working? 2 Answers

i can see my objects collide but OnCollisionEnter never called c# 1 Answer

how to access a script, and affect only one of the gameobjects its attached to? 1 Answer

OnTriggerEnter and Exit Not Aligned 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