-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using NavMeshSurface2d changes z position of an agent moving on the navmesh #21
Comments
Hi, So NavMeshSurface2d bakes navmesh, after that, its 'native' for unity. So lets look what surface do we get. The Z offset is kind of strange, what version of unity you are using? Rotate your scene and check is it flat against grid? On demo scene I see some bubble, maybe I have some defect in matrix transformation Also, check your offset. Agent sits flat on navmesh, but Z is 0.5, because of offset Please look as this issue #20 |
Unity version - 2019.3.0f6 "Giving the velocity.x a tiny value (0.0001f,Y,0) 'fixes' this - the agent will then move as expected." - I guess I can use this hack, but given my lack of experience I am not really able to distinquish if the other navigation related issues I am having are related to this or no. Also, you can ask questions on Navigation part of unity forum. - it's quite hard to tell when the forum should be used vs the issues here, in general I think GitHub issues are much better UI, search and can be tied more closely to an actual piece of code that might be in question (as it's now). Any advice on that? I am quite new to the ecosystem. |
Hi, If navmesh is okay, and only thing that doesn't work is agent movement with keys - its better to ask question of forum, as I don't have Agent 2d wrapper for you. Post new thread in https://forum.unity.com/forums/navigation.79/ with code snippet of how do you move agent. |
I know this was a while ago but did you end up finding a solution to this problem? I am having the exact same issue and have yet to find a solution to the Z axis being thrown off of 0.0f. |
@WoodlandDevelopment To set your Agent flat to the surface you can use Agent offset, but anyway you will have drift 0.0001f. The workaround is to disable position update and move gameobject by script The nextPosition is coupled to Transform.position. In the default case the navmesh agent's Transform position will match the internal simulation position at the time the script Update function is called. This coupling can be turned on and off by setting updatePosition. |
Hi @h8man, thanks for making this package, super handy and easy to use. I tried disabling updatePosition, but found that essentially broke collisions and let me travel through anything, not sure if this is unavoidable due to the coupling, or am I missing a step? Using the drift solution I had some small problems with stuttering (maybe due to float precision/rounding to zero?) but I added some dithering on the horizontal velocity so object tends back to Y axis, which let me user a more aggressive horizontal vel and eliminated the stuttering+drift.
|
@jcpickett1 Thanks for feedback. As I mentioned few times, I don't use Agent so I didn't get deep into it. But it seems Agent.NextPosition is simulated position and should include navmesh and obstacle avoidance. It is mentioned in manual https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent-nextPosition.html |
Whenever I hit play, my agent gets sent to the other side of the 2d plane. No matter the offset, its the same distance on the other side |
임시로 해결했습니다. 지금은 완벽히 고칠 수 없나 봅니다... h8man/NavMeshPlus#21
I have a player gameobject placed on a navmesh with NavMeshSurface2d rotated -90 on X just like the WIKI says. When the "game" starts the z of the transform holding the player gameobject is set to --0.7708252.
The runtime navmesh generation works, colliding works, agent.SetDestination works.
Manual movement (keyboard arrows) don't work, the player object get's stuck from time to time when moving up or down, probably to the Z missmatch.
As a workaround I have code in the update to set the Z to 0 whenever it's not (the value is getting set to the -0.7708252 constantly actually), but that results in some other issues and just feels bad.
Using NavMeshSurface doesn't generate the issue, but of course doesn't work for the 2d case anyway so quite hard to say if it's really NavMeshSurface2d but I have been randomly disabling components and that's my best bet now.
Let me know if you can help and if I can provide any more clues here.
Cheers
The text was updated successfully, but these errors were encountered: