Does navmeshagent use rigidbody or transform for movement?

Title says the question. The reason this is important is because I have started programming multiplayer code and I have to define if the movement is rigidbody or transform. When using .destination it’s just a vector3 and well a vector 3 could be used in both a rigidbody and transform so no information from that. I’m leaning towards rigidbody because of .desiredvelocity as being an option in navmeshagent but I just need some clarification here. I am hoping to sync with transform though due to performance reasons.

You can handle the movement yourself if you choose, only using the agent to give you a path.

I use .destination which moves the units for me. I just need to know if .destination is a rigidbody or transform move. If it’s a transform move I don’t need to change anything.

Whats the difference?

rigidbody move and transform move are the same (with the obvious exception that one shouldnt be used over the other when a rigidbody is involved).

Im getting the sense that you are using a rigidbody based whatever, which means it should be moving via rigidbody, but you’re talking about translate being the correct solution for you, which shouldnt be the case.

Of course not enough information to justify these wild assumptions.

because when programming networking I can sync either transform or rigidbody movement so I need to know what exactly agent.destination is doing.

Strangely enough I don’t know off the top of my head. Remove the rigidbody and see what happens. If you get a message that NavMeshAgent requires a rigidbody then it’s rigidbody. Otherwise it’s transform.

If I had to place bets I would say it’s transform. But as @JamesLeeNZ indicates, ridgidbody movement works by moving the transform. So ultimately there is no difference.

I had a thought (strange yes I know, and yes it did hurt a little bit).

Try constraining the rb axis and see what happens. I would assume that if its trying to move the rb correctly, it wont go anywhere if its locked down. Ive never tried to push a constrained rb though, so this might be entirely in-accurate.

btw, if you are using RB’s you should be syncing your RBs.

Think I’m just gonna do trial and error like boredmormon suggested. really I just need to sync y rotation to so that’s gonna be super easy :slight_smile:

I doubt navmeshagent will complain about it. im pretty sure it will work without it,

collisions on the other hand…

1 Like