Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 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
0
Question by craigiedon · Jun 29, 2014 at 07:50 PM · collisionnavmeshnavmeshagent

OnTriggerEnter not activating with NavMesh movement

I am making a stealth game where enemy movement is dictated by a NavMeshAgent and waypoints (marked by green waypoint flags). The enemy has a purple sight box as a child.

If the player walks into this sight box, the sight box's OnTriggerEnter() function is called which draws a red line to the player and plays an "alerted" sound.

alt text

However, there are situations where the OnTriggerEnter() function doesn't seem to activate when it clearly should. In particular, when the enemy has to significantly change direction to move from one waypoint to another, the enemy rotates to face the new point. The player can stand in the arc of this rotation and have the trigger not activate when it clearly and visibly should:

(Here the enemy is rotating from the bottom left flag in order to face and move to the bottom right flag)

alt text

I am unsure why this is occurring. I thought initially it was something to do with the code I had written within my OnTriggerEnter() function. However, after placing a print statement at the beginning of this function, I found out this wasn't true. In the cases where the enemy fails to spot the player, the OnTriggerEnter() function does not even get called in the first place!

Further component details:

The player has a Character Controller attached with a large collision capsule surrounding it. The enemy has a NavMesh Agent, AI script, and Box Collider on the main object. The sight box child has a Box Collider and a Script with an OnTriggerEnter function in it.

poacherworking.png (36.1 kB)
poacherspotted.png (54.3 kB)
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 craigiedon · Jun 30, 2014 at 11:44 AM 0
Share

The sight area is marked as a trigger

2 Replies

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

Answer by craigiedon · Jun 30, 2014 at 12:40 PM

Fixed the problem myself. The reason the trigger was activating sometimes but not always was that it was activating when the player moved into the sight box, but not when the sight box moved into the stationary player.

In order to have the trigger react to movement correctly, a rigid body must be placed on both the sight box and the triggering object (the player)

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 AlanGreyjoy · Oct 24, 2015 at 05:27 PM 0
Share

what a pain in the ass.

avatar image
0

Answer by IsouEU · Jan 29, 2021 at 11:31 AM

I am getting extremely disappointed with unity.

It was extremely difficult to make a multi input system to control the player (keyboard, click-walk, touchscreen joystick and physical joystick). The only solution I got at the moment was to activate and deactivate the "Character Controller" when moving with navmesh, and activating when navmesh finished the path or the player do another movement command.

But I'll probably have to destroy about 10 scripts and start all over again ...because:

Now working with triggers for the game logic, it works when the "Character Controller" is active, it means, the navmesh does not disable the trigger, because when the player is leaving the trigger by navmesh, the sucking "Character Controller" is disabled. I had already tried unsuccessfully a box collider as a child, and now I just try it with a rigibody ... which besides drastically lowering the game's FPS and don't solved the problem, thanks anyway ...

I'm trying to find a reason to use unity ... these things should be ready to use ... so that I could worry about the rest. And not trying to understand the stupid mind of whoever did it for basic things ...

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 IsouEU · Jan 29, 2021 at 12:41 PM 0
Share

Fixed the problem myself.

Felling like a retard, rigidbody not enough to trigger, u must have both... a collider AND a rigidbody(disable gravity and make kinematic, and sure you will still having undesired physics effects, but sucking trigger will finally work)...

Alot of variables and calcs slowing the system only to compare if the sucking position of character with 6 points of 3 axis...

I want to quit unity, have anyway to don't lose 1 year of work ? Spend hours trying to understand a retard $$anonymous$$d, i could solve it with 3 ifs... like in seconds ! This realy sux !

Now i can see why sucking modern games need the batman computer to make a cube in 10 fps

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Enemies using navmesh are bumping each other through solid objects 1 Answer

Does NavMeshAgent disable a gameObject's collider? 1 Answer

Stop collision of NavMeshAgents 0 Answers

Making a queue for NavMeshAgents 0 Answers

Navmesh agent collision. 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