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
1
Question by f-Schmitz · May 08, 2015 at 05:47 AM · charactercontrollernavmeshnavmeshagent

Player "teleports" on top of NavMeshAgent collider if the Agent is too close

hey guys,

I'm using the Unity NavMesh on Unity 5.0.1f1 and I have the problem that my player (which is controled by a PlayerController) teleports on top of a NavMeshAgent if the agent is too close to the player. I need the agent (my enemy) to be very close to the player, so the attack hits the player.

If the enemy stands still, the player can not walk on top of it. But if the player stands still and the enemy approch the player then the player is teleporteted on top of the enemy collider, regardless of its height. That happens also when the "Slope Limit" and "Step Offset" in the character controller is 0.

The enemy has a kinemetic rigidbody and a static boxcollider attached. The player has the playercontroller attached.

I've also attached a navmesh agent, for testing, to the player but then I can't jump and run across areas that are marked as "not Walkable" for the enemys.

Do you know how to fix this problem?

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 f-Schmitz · May 08, 2015 at 07:08 AM 0
Share

i just found a hint how to solve the problem here: http://answers.unity3d.com/questions/515021/are-charactercontrollers-and-navmeshagents-meant-t.html

He says, that setting the

 myAgent.updatePosition = false;
 myAgent.updateRotation = false;

can fix the problem. But in my tests, the navmeshagent than stays on the spawn point of the player. So I testet, to wrap the navmeshagent to the position of my player with

 myAgent.Wrap(transform.position);

That soloutions works kinda. The Player now can jump and enter places that are not in the navmesh but than the navmeshagent snaps to the closest point on the navmesh. I'm thinking of turning of the navmeshagend as soon as the player jumps or leaves the navmesh area, but I don't know if that is the right way.

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by florianveltman · May 29, 2015 at 02:23 PM

I have not set up a test but perhaps try attaching a navmesh obstacle to the player character and/or the enemies. The obstacle prevents the agents to move to that location. I guess the agents now just wanna stick to the spot they were at without being pushed around. If the player has a navmesh obstacle component attached to itself, the enemy won't be able to move to litterally the same spot but get close enough.

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 harryjc · Jan 11 at 03:18 AM 0
Share

This is the solution that worked for me. Placing a navmesh obstacle on the same object as the agent is likely to cause issues (colliding with itself), but placing a navmesh obstacle on the player character will stop the climbing problem. For better results, I made the navmesh obstacle a slightly larger radius than the capsule collider on the Player, and I shifted it down by half of the Player's height. This ensures that even if the Player does get up on top of the enemies for whatever reason, the navmesh obstacle is always pushing their heads out of the way to a slightly wider radius than the Player's collider, and so the Player falls back down to the ground.

avatar image
1

Answer by Bastoon · Jul 04, 2019 at 09:51 PM

Hi,

I had to remove the RigidBody of the ennemy and it doesnt teleport on top anymore and collision works.

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 realkillerx · Jun 06, 2021 at 01:07 PM 0
Share

2 years later, for anyone who may stumble upon this frustrating issue, i can confirm that Bastoon's solution works!

avatar image
0

Answer by baptistegr · Oct 03, 2018 at 07:54 AM

I have the exact same issue, did you manage to fix it? The player is controlled with a CharacterController, I set the slope limit to 0 and the step offset to 0 too, but when it gets really close from a NavMeshAgent it goes on top of it and continue to walk on his head.

Anyway to fix this?

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 ChrisNoGo · Feb 01, 2019 at 10:57 PM

Okay I think I found the source of the problem. I started having this exact same issue, but I also noticed that my NavMesh agent was intersecting with the collider of the gameobject. When I moved the Navmesh agent so that it wasn't touching the collider, I was no longer having my player teleport to the top of it.

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

8 People are following this question.

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

Related Questions

Are CharacterControllers and NavMeshAgents meant to work together? If so, how? 2 Answers

Is it possible to detect which area of a navmesh a navmesh agent is on? 1 Answer

"Nav Mesh Agent" messes up simple prototype player-gameobject. What's up with that? 0 Answers

Navmesh Agent Custom Controller 0 Answers

How to make AICharacterController able to walk on walls and ceilings? 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