ricardojmendez / UnitySteer

Steering, obstacle avoidance and path following behaviors for the Unity Game Engine
https://numergent.com/tags/unitysteer/
Other
1.21k stars 276 forks source link

TickedVehicle and DesiredVelocity setting #14

Closed mgoadric closed 11 years ago

mgoadric commented 11 years ago

I'm using UnitySteer in some crowd simulations. On my TickedVehicle, I have set CanMove to false, and want to use the DesiredVelocity in another script to run a mecanim animation, but have run into a few problems and questions.

In CalculateForces for TickedVehicle, I noticed that when CanMove is false, nothing is calculated, because of the if statement in line 150. Also, the DesiredVelocity does not take into account the possible corrections found in postprocessing in lines 219-234, like from SteerForNavmesh.

A related question; when postprocessing velocity is nonzero, should it be smoothly interpolated into the previously calculated velocity? Right now, when the agents leave the NavMesh, their velocity spikes up to MaxForce and does not look smooth.

ricardojmendez commented 11 years ago

Hi,

In CalculateForces for TickedVehicle, I noticed that when CanMove is false, nothing is calculated, because of the if statement in line 150.

Yes. If a vehicle cannot move, no forces are calculated to save that time.

Also, the DesiredVelocity does not take into account the possible corrections found in postprocessing in lines 219-234, like from SteerForNavmesh.

Correct, it's the other way around. DesiredVelocity means "This is where the vehicle wants to move, considering all behaviors", and the post-processing behaviors then take that value and adjust it.

A related question; when postprocessing velocity is nonzero, should it be smoothly interpolated into the previously calculated velocity?

The definitive answer is that "it depends". :-) It's all up to what fits the behavior that you're aiming for, but chances are that yes, smoothly interpolating towards it would be good on any case where you don't want sudden corrections.