Giter VIP home page Giter VIP logo

Comments (8)

h8man avatar h8man commented on May 17, 2024

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
image

Also, check your offset. Agent sits flat on navmesh, but Z is 0.5, because of offset
image

Please look as this issue #20
Also, you can ask questions on Navigation part of unity forum.

from navmeshplus.

DamodarSojka avatar DamodarSojka commented on May 17, 2024

Unity version - 2019.3.0f6
Rotate your scene and check is it flat against grid? - Not sure if that's what you mean but I used camera to just check if things are flat when looking at the from the side in 3D scene view, they are
Base Offest - was indeed set to 0.6875, no idea why, setting it to 0 doesn't help

"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.

from navmeshplus.

h8man avatar h8man commented on May 17, 2024

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.

from navmeshplus.

WoodlandDevelopment avatar WoodlandDevelopment commented on May 17, 2024

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

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.

from navmeshplus.

h8man avatar h8man commented on May 17, 2024

@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.

from navmeshplus.

jcpickett1 avatar jcpickett1 commented on May 17, 2024

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.

Vector2 dither = Vector2.right * 0.001f * (Random.Range(0,1) >= 0.5f ? 1 : -1);
_myNavAgent.velocity = _movementInput.ReadValue<Vector2>() * _playerSpeed + dither;

from navmeshplus.

h8man avatar h8man commented on May 17, 2024

@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

from navmeshplus.

Dragoonian avatar Dragoonian commented on May 17, 2024

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

from navmeshplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.