NavAgent Speed & Rigidbody Velocity

Hi all. My Question is this : How can i make [Rigidbody Velocity, NavAgent Speed] same. using same value.

I want to use both of them (not the same time tho.)

for example my unit got “3” Speed value. and I put that value on rigidbody velocity and NavAgent.speed.

Obviously the result was chaotic. they were not moving same speed as i wanted and if the speed changes the effect on it was totally different. because Rigid is using physics, Nav is using what ever… inside of it. i guess.

So, is there any way to use unified value both on R.V and NA.S resulting same movement speed?

Any ideas?

Very interesting question and while I don’t have a specific answer, I can probably offer an idea as to how I would try to solve it.

I would propose that the way you switch between your NavAgent and Rigidbody physics is to toggle the “Is Kinematic” flag on the Rigidbody. When letting Physics take over, disable the NavAgent and set “Is Kinematic” to false.

When you want the NavAgent to take over, then set “Is Kinematic” to true and enable your NavAgent. Now that would only be half the battle, the second half is making the transition believable. From the physics side of things going to your NavAgent, you can set your speed (the magnitude of your velocity vector), but you’d also have to set your acceleration, which means you’d need to keep track of your Rigidbody’s velocity and its change over time: currentAcceleration = (object.velocity - previousVelocity) / Time.fixedDeltaTime; (as an example).

When you switch back to Physics, you have your speed and acceleration from the NavAgent, so you can apply those forces when you turn the physics back on.

Keep in mind that when you are not using the Physics engine, you’ll still have to apply other outside forces (like the system’s gravity) to your NavAgent’s acceleration if you want things to start matching up correctly. Depending upon what you are trying to do though (like if on a flat surface), it may not be too big of an issue.

The biggest hurdle is toggling between the two systems and maintaining the correct motion when switching between the two, but I think it could be attainable.

Good luck! This sounds like it would be a really cool asset if one were available.