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 Joel_Shaji · Jul 21, 2020 at 07:38 AM · collisionrigidbodycollision detectionkinematicmoveposition

Kinematic RigidBody does not collide with Wall using MovePosition

I have a kinematic enemy capsule gameobject to which i have added a chase player script. To chase i have used LookAt() to make the enemy object face my player and then used MovePosition() to move it towards my player. The problem is it passes through all the walls I have placed in the way. The walls were static colliders so I assumed that was the reason, i gave a few walls a rigidbody component and added constraints for their position and rotation but the enemy object still passes through the walls. What am I doing wrong?

To summarise, my kinematic rigidbody being moved by a MovePosition function is passing through static colliders as well as non-kinematic rigid body colliders.

Comment
Add comment · Show 1
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 Joel_Shaji · Jan 18, 2021 at 12:22 PM 0
Share

The comment in the accepted answer by @mbro514 gives an elegant solution of using character controllers instead of kinematic rigidbodies for the enemy objects

2 Replies

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

Answer by mbro514 · Jul 21, 2020 at 03:34 PM

Kinematic Rigidbodies will always go through any collider, regardless of what type it is (dynamic, kinematic, or static). If you need an object to collide with other objects, but not be effected by the forces of physics, you could either use a Character Controller, or use a kinematic rigidbody and code a custom collision resolution for 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 Joel_Shaji · Jul 22, 2020 at 05:13 PM 0
Share

A kinematic rigid body does collide with a non-kinematic rigid body. I tested it out. If i removed the constraints i placed on the walls rigid body, the enemy capsule does collide with it but the result of this is that the wall also moves now. $$anonymous$$y doubt here was why does constraining a rigid body cause a kinematic body to go through it, unconstrained rigid bodies do not let kinematic bodies go through them even if they are stationary.

I solved it by making my enemy capsule a rigid body, the only force that could act on it was the projectiles my player shoots so i wrote a script to make the enemy capsule kinematic onCollisonEnter and back to non-kinematic onCollisonExit. That way for the few frames a bullet does hit it, it is kinematic.

Would love a better solution though if possible

avatar image mbro514 Joel_Shaji · Jul 22, 2020 at 06:14 PM 1
Share

The reason why your kinematic rigidbody is pushing your dynamic/non-kinematic rigidbody is this: Your kinematic rigidbody was not stopped by its collision with the dynamic rigidbody, so it penetrated the dynamic rigidbody's collider. However, since dynamic rigidbodies automatically resolve collisions, your dynamic rigidbody pushed itself backwards to resolve its collision with the kinematic rigidbody. This process of penetrating and moving away repeats itself so rapidly that it makes it look as if the kinematic rigidbody is pushing the dynamic one, but it's actually the dynamic pushing itself away. The reason why this pushing wasn't happening when the constraints were on is that the constraints were preventing the dynamic rigidbody from moving to resolve the collision, but the kinematic rigidbody was still able to penetrate it. I hope that this made sense. Anyway, what I advise that you do with your walls is that you make them static, and then do one of two things with your enemy characters: 1) You could give them dynamic rigidbodies, or 2) you could give them character controllers.

avatar image Joel_Shaji mbro514 · Jan 18, 2021 at 12:16 PM 0
Share

Thank you for the explanation! That cleared out why constraints were causing collisions to not happen. Using Character controllers seems like a good way to do this, thank you!

avatar image
0

Answer by SkillcraftHD · Jan 18, 2021 at 08:13 AM

You could just increase the mass of the rigidbody infinitily high so it won't be pushed.

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 Joel_Shaji · Jan 18, 2021 at 12:19 PM 0
Share

True, but I think a safer way would be to use a character controller as mentioned by @mbro514 in the comment above. Character controllers collide with static colliders and do not get affected by the collision forces.

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

237 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image

Related Questions

On Collision my Player Spins Wildly 2 Answers

seeking collision scenario solution : falling anvil vs. player 0 Answers

Collision between two kinematic rigidbody triggers 2 Answers

How to make kinematic rigidbody react to some collisions 6 Answers

isKinematic object doesnt collide with wall 1 Answer


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