Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
12
Question by ina · Jan 25, 2012 at 01:27 AM · collisionrigidbodycolliderstatickinematic

Having a kinematic rigidbody detect collision with a collider without a rigidbody

Is it possible to have a kinematic rigidbody detect when it has collided with another collider that does not have a rigidbody? (Are these static colliders)?

OnCollisionEnter does not seem to trigger

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

7 Replies

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

Answer by Invertex · Apr 19, 2018 at 08:09 PM

In 2017, Unity added the "Contacts Generation" setting in your Project Settings > Physics menu.



You can set this to "Enable Kinematic Static Pairs" to allow kinematic rigidbodies to get callbacks on collisions with static colliders.



alt text


cd50b4078465a59fe047027c6a624f99.png (29.6 kB)
Comment
Add comment · Show 7 · 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 Captain_Pineapple · Aug 16, 2018 at 08:08 PM 1
Share

Nice this is exactly what i needed!

avatar image RegdayNull · Jun 12, 2019 at 02:05 PM 0
Share

You sholda know, that I love u man (not gay)!

avatar image Invertex RegdayNull · Jun 12, 2019 at 11:20 PM 1
Share

There's nothing wrong with being gay so there's no need to say "not gay". But you're welcome.

avatar image korayaydemir276 · Mar 25, 2020 at 10:58 PM 0
Share

That didn't work for me., why ? And i can't find another solution on the internet..

avatar image Invertex korayaydemir276 · Mar 26, 2020 at 12:22 AM 1
Share

Double check your kinematic object and your static collider. Are both on the same layer? The kinematic object has its rigidbody active? In your Project Settings>Physics, is the layer the objects are on set to collider with eachother? Did you put a breakpoint or Debug.Log at the start your OnCollision/Trigger Enter method to see if it's being called at all?

avatar image arkilis korayaydemir276 · Jun 20, 2020 at 09:43 PM 1
Share

You probably are doing a 2d game here, I tried the same, not working either.

avatar image samra2494 · Aug 11, 2020 at 07:20 AM 1
Share

Thanks a lot.. You have saved me weeks :) :D thanks again, this is what I actually want :)

avatar image
39

Answer by mustafa · Sep 10, 2013 at 11:45 AM

Yes, you can achieve the effect that you want by make it not kinematic rigidbody and checking all the constraints for freeze position and freeze rotation. This way your rigidbody is not effected by physics but can still detect collision with OnCollisionEnter(Collision c), OnCollisionStay(Collision c) and OnCollisionExit(Collision c)

Comment
Add comment · Show 5 · 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 VSZM · Dec 07, 2014 at 11:10 PM 2
Share

I would accept this as the answer, thanks.

avatar image W4rf4c3 · Nov 08, 2017 at 02:02 PM 0
Share

This should be the accepted answer. The alternative of $$anonymous$$inematic is Freeze contraints and it keep the collider's properties.

avatar image Ronsu900 · Nov 13, 2017 at 11:19 AM 0
Share

I wanted to know something like this. thanks for sharing that nice trick!

avatar image buckbeak_fahim · Dec 21, 2020 at 07:58 PM 0
Share

THIS is the perfect answer. What he means is:

  • Turn the Rigidbody Dynamic INSTEAD OF Kinematic

  • Go to Constraints

  • Uncheck Freeze Positions X, Y

  • Check Freeze Rotation Z

Here's the collision matrix from unity docs for clarification.

alt text

screenshot-2020-12-21-145446.jpg (138.0 kB)
avatar image buckbeak_fahim · Dec 21, 2020 at 10:19 PM 0
Share

THIS is the perfect answer. What he means is:

-Turn the Rigidbody Dynamic instead of Kinematic -Go to Constraints -Uncheck Freeze Position X, Y -Check Freeze Rotation Z

And the laws of physics in Unity are held up detecting collisions. The collision matrix from link text is given below for clarification. alt text

screenshot-2020-12-21-145446.jpg (138.0 kB)
avatar image
6

Answer by syclamoth · Jan 25, 2012 at 01:49 AM

No, it's not possible to have a kinematic rigidbody detect collisions with static colliders. Look it up in the manual- there's this nice little chart down the bottom that explains all of this.

Comment
Add comment · Show 8 · 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 ina · Jan 25, 2012 at 06:58 AM 0
Share

Is there a workaround then to having a static collider detect the colliding kinematic rigidbody?

avatar image Kailas · Jan 25, 2012 at 08:12 AM 1
Share

I could think of several million reasons off the top of my head why someone might want to detect when a kinematic rigidbody is hitting something, even if normal physics aren't applied, see my answer below.

avatar image syclamoth · Jan 25, 2012 at 08:18 AM 0
Share

Well, yeah- you might want to detect when the objects are passing through each other, but they don't hit each other if the rigidbody is kinematic. The key point here is 'Collison' - if you want messages to get sent, make the collider on the rigidbody a trigger, and use the OnTriggerEnter message ins$$anonymous$$d. You won't get point and normal data, or anything else that relies on the physics system, but the signal will work.

avatar image ina · Jan 25, 2012 at 09:57 AM 0
Share

OnTrigger only works on the static collider, but what about something that is on the moving platform (ins$$anonymous$$d of having to put a script in all static colliders)

avatar image ina · Jan 25, 2012 at 10:04 AM 0
Share

I ended up just using a raycast. Not sure if that will affect performance much

Show more comments
avatar image
2

Answer by Kailas · Jan 25, 2012 at 07:56 AM

It isn't directly possible, no.

But if you put another game object under the kinematic rigidbody that contains a trigger with the exact same collider as the parent and a kinematic rigidbody of its own, the trigger will (in theory) receive trigger messages from whatever they hit since they'll always be in the same position.

I have never actually tried this so it might not work if unity decides it doesn't feel like it.

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
0

Answer by glitchers · Aug 03, 2016 at 03:13 PM

I had success to get a collision (hit point, normal etc) with a kinematic rigidbody with a trigger collider with the static world collider.

I was using OnCollisionEnter but that only gave me the collider, not the hit point & normal. Because I was moving the kinematic rigidbody, before I moved it in FixedUpdate I used Rigidbody.Sweep which gives has an out for RaycastHit.

In my tests this gave the same result as the non-kinematic non-trigger rigidbody colliding with the world.

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
  • 1
  • 2
  • ›

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

Preventing objects from intersecting with minimal physics 3 Answers

Make isKinematic false when touching a Collider? 1 Answer

Controll squeeze of rigidbody between static collider and kinematic rigidbody. 1 Answer

Object gravity but no collisions 0 Answers

Collisions between two rigidbody's and scripting collisions problem 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