|
AnnMarie Otoole
Addicted scripter
Join date: 6 Jan 2007
Posts: 162
|
11-14-2008 22:01
I have a vehicle but it runs on autopilot so no one is using controls to steer it. It has azimuth direction of motion vector or angle available which it follows nicely. How do I use the vehicle controls, to make the X vector of the vehicle align with the direction of motion? (As opposed to motion following angle in a conventional vehicle.) I can easily make it work by going non-phs llSetRot(azimuth) and phys again but that is cheating. It is moving slowly and I have 1 second updates. I can check the X direction, and get the error angle, but how do I apply llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION,angular_velocity) so it goes the shortest direction to the heading and damps critically to the heading?
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
11-15-2008 01:06
Have you tried a low angular deflection timescale (VEHICLE_ANGULAR_DEFLECTION_TIMESCALE)?
|
|
AnnMarie Otoole
Addicted scripter
Join date: 6 Jan 2007
Posts: 162
|
11-15-2008 20:48
If anyone is interested, here is how I solved the problem.
azimuth is a direction vector, the desired heading for the vehicle as used in the Direction Motor. azimuthRot = llRotBetween(<1,0,0>,azimuth); azimuthEuler = llRot2Euler(azimuthRot); vehiclEuler = llRot2Euler(llGetRot()); Angle between vehicle and azimuth:- angle = vehiclEuler.z - azimuthEuler.z; if angle-PI>0) angle -= TWO_PI; if(angle+PI<0) angle += TWO_PI; The value of angle will have a sign representing the direction of rotation for the lowest angle to turn. You can use this as a proportional Angular force to apply. If it is unstable, reverse the sign of angle.
|