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 Eldaran · Jun 07, 2014 at 02:55 PM · collisionrigidbodyoncollisionenterkinematic

How to make kinematic rigidbody react to some collisions

I have a number of objects with rigidbodies on my scene. Some of them are kinematic to make them stable. However, if a kinematic object is hit by a special type of object, it needs to react as if it was not kinematic, i.e., it needs to become non-kinematic, and react to the same collision that makes it non-kinematic.

If I use

 OnCollisionEnter(Collision collision)
 {
     rigidbody.isKinematic = false;
 }

the object becomes non-kinematic, but fails to react to that collision. My guess is that the collision has already begun, changing "isKinematic" in "OnCollisionEnter" is too late.

Which means, I somehow need to know the collision right before it really happens.

Any suggestions?

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

6 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Jeff-Kesselman · Jun 07, 2014 at 02:57 PM

Rather then making it kinematic, you can give it its own layer and use the Physics settings to control what other layers it interacts with.

http://docs.unity3d.com/Manual/class-PhysicsManager.html

Note that this will ALSO prevent it from applying forces to anything it is set not to interact with.

If thats not what yo want then yo hare likely into scripting specific application of forces from specific objects.

Comment
Add comment · Show 1 · 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 Eldaran · Jun 08, 2014 at 12:55 PM 1
Share

I need other objects to hit kinematic ones, but kinematics should not react to collisions and stand still, unless the object hitting the kinematic one is of special type.

If I use layers, they won't hit each other at all.

avatar image
1

Answer by oasisunknown · Jun 08, 2014 at 07:50 PM

you could use your code then add a force to the object yourself to get it moving. (series of events.) 1. gets hit 2. turns itself non kinematic 3. gives itself a large push in the right direction. 4. everything else that happens.

Comment
Add comment · Show 1 · 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 Eldaran · Jun 08, 2014 at 08:20 PM 0
Share

Unfortunately, I have to make sure both objects (the one hitting and the one getting hit) react as if nothing was special. I don't think it is feasible to mimic the reactions of objects as if physics engine was in use.

avatar image
0

Answer by legion_44 · Jun 08, 2014 at 08:32 PM

I think You can make another Collider that will be trigger and set it to be bigger than actual collider (the bigger velocities, the bigger offet You will need to use) and then in OnTriggerEnter set rigidbody to non-kinematic. This should work.

Comment
Add comment · Show 1 · 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 Eldaran · Jun 23, 2014 at 10:08 PM 0
Share

This can make objects collide even if they are not going to collide in their actual trajectories. I am thinking of using an extra (invisible) object that is always where the actual object will be in the next frame. It is similar to this, but with higher possibility. There can be some extreme cases where it will malfunction, but I guess there is no better way.

avatar image
-2

Answer by rhbrr5hrfgdfgw · Jun 08, 2014 at 09:29 PM

 function OnCollisionEnter(collision : Collision) {
     rigidbody.isKinematic = false;
 }
Comment
Add comment · Show 1 · 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 Eldaran · Jun 23, 2014 at 10:05 PM 0
Share

Thanks, but the problem is not caused by a faulty script.

avatar image
-2

Answer by rhbrr5hrfgdfgw · Jun 08, 2014 at 09:37 PM

 function OnCollisionEnter(collision : Collision) {
     rigidbody.isKinematic = false;
 }
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

26 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

Related Questions

Collision Only being detected on one of the objects involved in the collision - C# 0 Answers

what object hit me? easy rigidbody question 1 Answer

[SOLVED] Desactivate pushing forces between two objects 2 Answers

Enemy rigidbody and bullet collisions 1 Answer

Child Rigid Body collision 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