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 lampshade · Sep 29, 2010 at 10:21 PM · detectionrigidbody-collision

RigidBody Collision Detection

Hi,

I noticed a new feature with the Rigid Body component, 'Collision Detection'. I have it set to Continuous and it is unstable!

The code that I have is defined in my PlayerMoveScript C# file:

void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "GameObject_1") { ON_TRIGGER = true; } else if (other.gameObject.tag == "GameObject_2") { ON_TRIGGER = true; } //.... }

void OnTriggerExit(Collider other) { if (other.gameObject.tag == "GameObject_1") { ON_TRIGGER = false; } else if (other.gameObject.tag == "GameObject_2") { ON_TRIGGER = false; } }

so I referece the ON_TRIGGER bool type in another script:

void Update()
{ 
    Debug.Log(PlayerMoveScript.ON_TRIGGER);
}

I get true, false, true, false, true, false when I am ON the game object and when the RigidBody->Collision Detection feature is set to Continuous, Discrete or Continuous Dynamic.

Is this a performance issue? It worked fine in 2.6.1 (without this additional feature)

The player has these components attached:

MeshRenderer (which really doesn't have anything to do with CD) RigidBody (with Collision detection to Discrete) Capsule Collider

The game object has these components attached:

MeshCollider MeshRenderer RigidBody (with CD to discrete)

is there a mismatch or something? The player has a child object "bodyMesh" with the same components.

Comment
Add comment · Show 4
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 spinaljack · Sep 29, 2010 at 11:20 PM 1
Share

continuous and dynamic collision detection only works for sphere, box or capsule colliders. Also the object gets push away from the collision.

avatar image lampshade · Sep 29, 2010 at 11:26 PM 0
Share

The player is colliding with a $$anonymous$$eshCollider. The player is envelopped within a Box Collider. $$anonymous$$y guess is that their are a number of things that could be wrong, so let me post everything that is attached to the relevent game objects . . .

avatar image Peter G · Sep 30, 2010 at 12:59 AM 0
Share

You DON'T want to use continuous collision detection unless you are using very fast moving objects (fast enough to go from 1 side of the collider to the other within 1 frame i.e. passes through). The performance hit is rather substantial for continuous collision detection.

avatar image lampshade · Sep 30, 2010 at 03:57 AM 0
Share

How can I get my boolean varaible to stay true? It worked fine with 2.6.1

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Proclyon · Nov 10, 2010 at 09:31 AM

When you use a rigidbody u need to consider to use FixedUpdate() rather than Update(), behaviour like the one you described can occur due to slight difference in the timing for the PhysX engine components.

It's all a very precisely tuned clock and when checking for collisions using Continous collision detection you are asking the machine to check a lot more, specifically usefull for checking FAST moving objects, but it costs a lot of effort, having to tune all the time would make for a lot of extra work so Unity3D assumes you want best performance with collision detection unless you need a more specific check for precise calculation (Which in my opinion is a wise decisions).

Unless the objects are going very fast don't use Continuous or ContinuousDynamic collision detection systems. And when using a rigidbody, use FixedUpdate wherever possible, even though I have to admit I am not always doing so myself, I'm not fully confident I understand what is going on when I do use it and I do not like that at all.

Also see the user manual references for more on this

FixedUpdate should be used instead of Update when dealing with Rigidbody.

From: Here_FixedUpdate

and:

Continuous Used for objects which the Continuous Dynamic detection needs to collide with.(This has a big impact on physics performance, leave it set to Discrete, if you don't have issues with collisions of fast objects).

Continuous Dynamic Used for fast moving objects.

From: Here_Continous

Hope it helps :)

I'm having some serious problems understanding just what is going on under the hood with all the collisions and who's calling what. The Unity3D actors are making it tricky for me. Used to doing all the work myself now it's gotta match the engine and components build that exists so it's quite easy to get lost in the maze.

Just keep backtracking and asking where it went wrong if you can't get out!

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 lampshade · Nov 15, 2010 at 10:35 PM 0
Share

The problem, was that I had a $$anonymous$$eshCollider attached to my game object. It needed to be a Box Collider.

avatar image Proclyon · Nov 16, 2010 at 07:55 AM 0
Share

ok good to hear the problem is solved

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

No one has followed this question yet.

Related Questions

Inverse function of OnTriggerStay? 3 Answers

how to check if one object is colliding with another 1 Answer

Detection if a GameObject is below you or next to you? 1 Answer

Enemy detection while pathfinding through the map 1 Answer

Detect Trigger Enter for One Game Object 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