Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by tallesmaziero · Nov 05, 2018 at 08:34 AM · collisioncollidercolliderscollision detectionkinematic

How i prevent 2 obejcts with kinematic checked in both rigidbodies collide?

I have this AI in enemies that goes to the player, i want to avoid that 2 objects collide (both of them are with kinematic checked in their rigidbodies). I need this because of the animations (they slide at the transition if kinematic is not checked) and i am using navmeshagent for the AI movement.

I went to Physics and disabled the layers collision but it not worked.

There is a workaround?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by UnityCoach · Nov 05, 2018 at 03:01 PM

When moving a Kinematic Rigidbody, either through its transforms, or preferably with Rigidbody.MovePosition(), you need to check for collisions yourself, as Kinematic Rigidbodies will

  1. not be applied any force (gravity, nor forces),

  2. not suffer collisions, although other Rigidbodies will collide with them like they had an infinite mass.

You can simply use Physics.RayCast(), or better use Physics.BoxCast(), or Physics.SphereCast() to detect possible collisions on the way.

Something like this :

 void FixedUpdate ()
 {
     // if nothing is in the way along 1 unit ahead
     if (!Physics.RayCast (transform.position, transform.forward, 1f)
     {
         // move rigidbody 0.5f forward
         rigidbody.MovePosition (rigidbody.position + transform.forward * 0.5f);
     }
 }
Comment
Add comment · Show 4 · 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 tallesmaziero · Nov 07, 2018 at 10:16 AM 0
Share

I'm using Nav$$anonymous$$esh to the movement. I made some tests and even with kinematic unchecked they are still colliding.

avatar image UnityCoach tallesmaziero · Nov 07, 2018 at 11:58 AM 0
Share

Nav$$anonymous$$esh Agents will ignore collisions.

It is often said that Navigation doesn't work with Physics. This isn't true, they just don't play nice with each other. You have to handle this agents/obstacles collisions.

You can use Obstacles. Agents will avoid them. If obstacles are set to Carve the Nav$$anonymous$$esh, it will allow agents to reroute to destination. Otherwise they will simply stop when stuck in a dead end.

You may also use GetPath(), and move the agent on the path yourself, checking for collisions using Physics.RayCast or BoxCast.

avatar image tallesmaziero · Nov 07, 2018 at 12:01 PM 0
Share

I see. But the real problem is that i'm spawning obejects as enemies, like an gropu of similar enemies. They have to go to a certain position to attack my player. But they collide with each other.

avatar image UnityCoach tallesmaziero · Nov 07, 2018 at 12:09 PM 0
Share

Here are a few links to help you :

https://forum.unity.com/threads/navmesh-agents-to-avoid-other-agents.500416/

https://docs.unity3d.com/$$anonymous$$anual/nav-$$anonymous$$ixingComponents.html

https://www.youtube.com/watch?v=4$$anonymous$$j6YUPLWCw

avatar image
0

Answer by xainulabdeen · Nov 07, 2018 at 12:13 PM

Try to Change Collision Layers on Collision Matrix Edit > projectSettings > Physics

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 tallesmaziero · Nov 07, 2018 at 12:14 PM 0
Share

I already tried that.

avatar image xainulabdeen tallesmaziero · Nov 07, 2018 at 12:23 PM 0
Share

https://www.youtube.com/watch?v=S2m$$anonymous$$6$$anonymous$$Fdv0I see video till 5$$anonymous$$ts add Nev$$anonymous$$eshObstacle component to your agents and Check Property Carve so that it will make your objects static but moveable .

avatar image xainulabdeen xainulabdeen · Nov 07, 2018 at 12:24 PM 0
Share

They will never overlap and find alternative path

avatar image
0

Answer by tallesmaziero · Nov 07, 2018 at 12:41 PM

I made 2 videos to show what is happening. The video with 1 enemy is the way i want. The video with the 2 enemies is whats happening they keep pushing each other.

https://photos.app.goo.gl/ckxwUYwCKme57Dbt6

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 tallesmaziero · Nov 07, 2018 at 12:45 PM 0
Share

i need them to not collide with each other.

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

226 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

Related Questions

Colliders for tunnels 0 Answers

Collisions Detection Functions Not Called, Walking Through Walls 2 Answers

[SOLVED] Colliders aren't working properly. Clipping through ground. 1 Answer

my colliders don't work properly 2 Answers

Ignore collision based on position 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