I am trying to convert some of my C++ add-on modules into Lua scripts. One problem I am having is getting the flight control animations to work.
For example, here is the elevator implementation
In clbk_setclasscaps(cfg):
This script runs, but when I test fly the aircraft, the elevator applies a force, but the corresponding animation doesn't work.
This is the corresponding code in my C++ module:
In clbkSetClassCaps(FILEHANDLE cfg):
In DefineAnimations(void):
I have other animations working like wheels, but none of the flight control animations want to work, yet the script runs and I can't see any obvious problems with my script code. Can anybody with fresh eyes see what I am missing?
Additional information: I can set the animation state using vi:set_animation(anim_elevator, 1) in clbk_poststep() and that moves the elevator mesh. Do I explicitly have to pass the flight control inputs to the animations? I thought they were already linked when the control surface was created?
For example, here is the elevator implementation
In clbk_setclasscaps(cfg):
Code:
vi:create_controlsurface(AIRCTRL.ELEVATOR, 7, 0.7, {x=0, y=0, z=-17}, AIRCTRL_AXIS.XPOS, anim_elevator)
anim_elevator = vi:create_animation(0.5)
elevator =
{
type = 'rotation',
mesh = 0,
grp = {134,142},
ref = {x=0,y=-0.9223039,z=-4.268489},
axis = {x=1,y=0,z=0},
angle = 33*RAD
}
vi:add_animationcomponent(anim_elevator,0,1,oapi.create_animationcomponent(elevator))
This script runs, but when I test fly the aircraft, the elevator applies a force, but the corresponding animation doesn't work.
This is the corresponding code in my C++ module:
In clbkSetClassCaps(FILEHANDLE cfg):
C++:
CreateControlSurface(AIRCTRL_ELEVATOR, 7, 0.7, _V(0, 0, -17), AIRCTRL_AXIS_XPOS, anim_elevator);
In DefineAnimations(void):
C++:
static UINT EGrp1[2] = { 134, 142 };
static MGROUP_ROTATE elevator(0, EGrp1, 2, _V(0, -0.9223039, -4.268489), _V(1, 0, 0), (float)(33 * RAD));
anim_elevator = CreateAnimation(0.5);
AddAnimationComponent(anim_elevator, 0, 1, &elevator);
I have other animations working like wheels, but none of the flight control animations want to work, yet the script runs and I can't see any obvious problems with my script code. Can anybody with fresh eyes see what I am missing?
Additional information: I can set the animation state using vi:set_animation(anim_elevator, 1) in clbk_poststep() and that moves the elevator mesh. Do I explicitly have to pass the flight control inputs to the animations? I thought they were already linked when the control surface was created?
Last edited: