SDK Question Animation only works in one direction (polarization)

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Can anyone tell me why (since somewhere in Orbiter Beta) my wheel rotation animations only work if heading in a northerly direction? (heading 330 deg on cape runway 15/33)
It stops from 90 deg either way.........

Is there a fix ?

Code:
 if (iop > 1)iop=0;
    
    if (hspd > 0.4) 
	{
    double aspeed = hspd*1.5;
    if (iop > 1)iop=0;
    if (hspd > 30) aspeed = 30; 
    iop = iop + (aspeed /200);//300
     
    if (hspd <= 0.4) iop=0;
    
    
    if ( GroundContact() && gear_proc < 0.05) {vspdwn = 0; 
	SetAnimation (anim_wheel, iop);}

	}

and
Code:
if (GetAirspeedVector (FRAME_HORIZON,v)) 
 
		hspd = (v.z );

if I change to (GetAirspeedVector (FRAME_GLOBAL,v)) working direction is reversed.........?
 
Last edited:

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,862
Reaction score
2,126
Points
203
Location
between the planets
Can't be sure since I've never worked with this, but a quick glance at the documentation tells me that:

•FRAME_HORIZON: Returns velocity vector in the local horizon frame (x = longitudinal component, y = vertical component, z = latitudinal component)

In other words, z in this frame is movement along the latitude, which would be north or south, and presumably when heading south it would be negative (and since you never reset iop when it falls below 0, that would also result in no animation).

This seems more like what you need:

•FRAME_LOCAL: Returns velocity vector in the vessel's local frame of reference

I.e. z here would always be movement of your vessel along its own z-axis.

Also, just a cosmetic suggestion, don't be afraid of longer variable names. The auto-completion features of your IDE aren't just there for fun, they're there so you can give your variables readable and comprehensible names without having to type them in full every time ;)
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
I think it should be GetAirspeed and not the vector, or compute the length of v. Surely not just the z component
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Yep, thanks jedidia. That works.

Thanks too fred18. You're probably right for more accuracy, but it's only simply to "get the wheels turning" :thumbup:
 
Top