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 /
avatar image
0
Question by AceToAced · May 19, 2018 at 07:40 AM · colliderstriggersiskinematic

OnTriggerEnter and Exit triggering simultaneously constantly

I have a NavMeshAgent (Enemy) that patrols around. it has two colliders one on the parent and one on the child. One much larger that the other. the child collider is use to see if the player is in range to be chased and the parent collider is to see if it is range to attack the player. The child collider OnTriggerEnter/Exit/Stay gets triggered appropriately but the Parent Collider triggers OnTriggerEnter/Exit simultaneously and constantly when the player is in the parents collider.

When i select the IsKinematic box on the rigidbody of the parent this problem is solved and OnTriggerEnter/Exit gets triggered at the correct times. the problem is that i would like to apply forces to my enemy and IsKinematic removes that option. Any idea why turning on isKinematic solves this problem? and is there a solution to this?

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
3
Best Answer

Answer by NEGATIVERAGDOLL · May 19, 2018 at 12:51 PM

Instead of using triggers you might want to look into using Vectors, it is a lot easier and usually works a lot better. For example you could use something like
if (Vector3.Distance(other.position, Player.position) <= 10) other is the object and player is the player. It will check the distance between you and the enemy object, if it equals 10 or below ("<" means below) whatever you want to happen can happen. You can then do the reverse for if you're a certain distance away.

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 AceToAced · May 20, 2018 at 01:41 AM 0
Share

Thanks for the help, I think your approach should fix the problem.

avatar image NEGATIVERAGDOLL AceToAced · May 22, 2018 at 05:59 AM 0
Share

No problem, if you need anymore help don't hesitate to ask :)

avatar image
1

Answer by jonnydredd · May 20, 2018 at 03:26 AM

No idea about why Kinematic would cause this, but I'm pretty sure swapping the colliders would solve this, as in, put the smaller collider on the parent and the larger chase box on the child. It seems like if the parent is triggered then it triggers the child too? Perhaps another method would be to have no collision on the parent, but have two children, one for chase box one for close collision, so they are called separately, without considering each other.

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 Guynelk · Feb 12, 2020 at 04:00 PM

Triggerstay and triggerexit will work simultaneously if you have a rigidbody to the parent and child. I had the same problem and when I deleted the parent's rigidbody, the collisions in child whose collision I wanted to detect worked correctly. I don't know if it will work for you but I took several days or even a week to find out

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

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

87 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

Related Questions

A child component is triggering its parent collider. 1 Answer

Why my "Is Trigger" box colliders are physically colliding with other colliders? 1 Answer

Does OnTriggerStay ignore layers? 1 Answer

Problem with multiple colliders in a trigger 2 Answers

Unity's collision system VS designing my own basic collision system 0 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