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
2
Question by nution · Aug 16, 2014 at 10:53 AM · navmeshnavmeshagentnavigationnav mesh

NavMesh issue with spawning players

We use a script that says "take this objects transform, then randomly choose a position at 360 degrees and 100 units out, and spawn an enemy somewhere on the perimeter of that circle."

If I turn off the NavMesh and just run it, the script itself performs great. It will drop enemies randomly around that perimeter.

However, when I turn NavMesh on, they still spawn where they are supposed to, but some of them will "shoot" off to some other point of the map. Its almost like the NavMesh forces them off to some other "more suitable" point of the map. If I bake a mesh with 0 objects in the scene, and it is a perfectly solid blue plane, then they act fine. If I have a lot of objects in the scene and bake, then you get all the intricate geometry of the NavMesh. Which, seems to be the issue. The more complex, the more "dead" areas I have. Where now all the enemies actually span in the circle, but are immediately and very quickly shot over to some other point of the mesh that usually isn't inundated with these lines in the mesh.

To clarify, I know how to setup NavMesh parameters, and have tried an immense amount of variations. My actual ground in 100% flat through the whole thing. The only things I have really are height, to say what enemies can fit under, and radius, being how far around objects to avoid.

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 Alessio89 · Aug 16, 2014 at 11:10 AM 1
Share

Do the spawned objects have script attached to them that control the Agent? If so, have you checked that you don't do any calculations on remainingDistance while no path has been assigned yet? I once saw a similiar issue and turned out that my programmer friend did some calculations before giving a destination and the agent bugged that way. I might be completely off, but i tought to share my experiences.

3 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by nution · Aug 18, 2014 at 11:53 PM

It turned out (for some odd reason) we had to turn off the NavMeshAgent in script, then turn it back on just after the character spawned. I also think this has something to do with the fact that the enemies are pooled, and just respawned over and over and never actually start the game instantiated and on the ground.

So, if you come across this issue, I would say to turn off the NavMeshAgent component by default, then when you spawn or respawn, activate it, when the character dies and is "destroyed" (more like deactivated) THEN turn it off, and keep it off till you instantiate him again in his new location. MAybe wait a half second after he spawns, then activate. This solved it for us.

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 Alessio89 · Aug 19, 2014 at 07:22 AM 0
Share

That's good to know :) $$anonymous$$ark your own answer so other will know how to solve it :)

avatar image Gigoorin · Aug 26, 2019 at 09:04 PM 0
Share

This still works :D

avatar image
1

Answer by lazer · Mar 12, 2017 at 06:14 PM

Same problem; this solution worked for me. Would still like to know what the actual reason this works is though, i.e. if its a specific number of frames, wall time, moon phase, UT HQ coffee pot state, etc.

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 Zeefles · Nov 05, 2017 at 03:24 AM 0
Share

still running into this issue in 2017. This is a work-around perhaps an explanation from someone or a bug fix?

Thanks guys

avatar image
0

Answer by nathanwick · Jan 12, 2019 at 07:29 PM

Still running into this issue in 2019 lol.

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 Gigoorin · Aug 26, 2019 at 09:07 PM 0
Share

So was I but if you read lazers response it works perfectly. In the start function just disable and then re-enable the navmesh agent. Hope you get it working :D

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Nav mesh agent position 1 Answer

Duplicated NavMesh Agents not moving 0 Answers

NavMesh agent snaps to wrong mesh 0 Answers

NavMeshAgent cannot walk around the obstacles 0 Answers

NavMeshPath.corners.length is always 0 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