Board index FlightGear Development Aircraft Cockpit development

Cockpit Shaking

Discussion about creating 2d and 3d cockpits.

Cockpit Shaking

Postby cyyz_spotter » Sun Aug 23, 2020 7:06 pm

I have been trying to implement cockpit shaking into the An-124 but I have no idea why my Nasal script is not doing anything, I know it works because I tried manually toggling it through the property browser. It is supposed to use the "gear-compression-norm" property for the front gears to determine when it will trigger the cockpit shake which I borrowed from the 727. Does this have something to do with the fact that it is an Yasim aircraft and the 727 is an JSBSim aircraft? Here is the code
Code: Select all
var shakeEffectB727 = props.globals.initNode("/systems/shake/effect",0,"BOOL");
var shakeB727 = props.globals.initNode("/systems/shake/shaking",0,"DOUBLE");
var rSpeed = 0;
var sf = 0;
var n_g_c = 0;
var n_g_l = 0;
var n_g_r = 0;

var theShakeEffect = func{
   n_g_c = getprop("/gear/gear[0]/compression-norm") or 0;
   n_g_l = getprop("/gear/gear[1]/compression-norm") or 0;
   n_g_r = getprop("/gear/gear[2]/compression-norm") or 0;
   rSpeed = getprop("/gear/gear[0]/rollspeed-ms") or 0;
   sf = rSpeed / 94000;

   if (shakeEffectB727.getBoolValue() and (n_g_c > 0 or n_g_l > 0 or n_g_r > 0)) {
      interpolate("/systems/shake/shaking", sf, 0.03);
      settimer(func {
         interpolate("/systems/shake/shaking", -sf * 2, 0.03);
      }, 0.06);
      settimer(func {
         interpolate("/systems/shake/shaking", sf, 0.03);
      }, 0.12);
      settimer(theShakeEffect, 0.09);   
   } else {
      setprop("/systems/shake/shaking", 0);
      setprop("/systems/shake/effect",0);      
   }      
}

setlistener("/systems/shake/effect", func(state){
   if(state.getBoolValue()){
      theShakeEffect();
   }
}, 1, 0);
cyyz_spotter
 
Posts: 19
Joined: Fri Jul 10, 2020 3:57 pm
Location: Canada
Callsign: C-FWES
Version: 2020.3
OS: Windows 10

Re: Cockpit Shaking

Postby benih » Fri Dec 11, 2020 9:04 pm

I think that the property "/systems/shake/shaking" is aircraft/system specific and not a generic property of the simulator.
This may be the reason why you don't see it doing something....
User avatar
benih
 
Posts: 395
Joined: Tue Aug 15, 2017 9:34 am
Callsign: D-EBHX

Re: Cockpit Shaking

Postby benih » Sat Dec 12, 2020 12:43 pm

See also FGCamera, which also has a cockpit shaking effect: viewtopic.php?f=6&t=21685
User avatar
benih
 
Posts: 395
Joined: Tue Aug 15, 2017 9:34 am
Callsign: D-EBHX


Return to Cockpit development

Who is online

Users browsing this forum: No registered users and 1 guest