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

Objects spinning #12

Closed uncasid closed 11 years ago

uncasid commented 11 years ago

Our project is being developed in space and uses X/Y/Z movements. I have noticed on some of our models that when it is heading in the Y (+/-) direction, it does a deathroll (like what an alligator does). I have tried to work it out of the system but cannot figure out why it does it.

I am using the autonomous vehicle script and giving them the steer to wander + the other typical stuff, and then I attach them to a point.

uncasid commented 11 years ago

I have a feeling it is in the wander code. I have the weight set to 10, with max lat side / up at 1, and smooth at 0.005. I noticed changing the smooth rate helped reduce it, but doesn't stop it

ricardojmendez commented 11 years ago

SteerForWander doesn't maintain a concept of "up", so for non-planar vehicles it is possible for a vehicle to do exactly that. By altering the smooth rate what you're telling it is to blend the value into the accumulator at a slower rate, but that will not prevent it.

It should be easy enough however to create a derivative SteerForWander that handles some banking, and prevents the vehicle's from going beyond whatever inclination range you consider acceptable.

An even better option option is to do this by making a descendent of AutonomousVehicle which overrides AdjustOrientation, which would consider this after all steerings have been calculated.