Profile image

##(SOLVED!!!) NEED FT CODE for detecting if craft is moving Backwards even without an input##

1,212 An2k  4.6 years ago

Guys I need a code for a condition on an IF Else statement CONDITION ? 1: 0 on beacon's input for
To detect backward movement even w/o input like example using Pitch for engine control and you pitch down then releasePitch so still moving backwards without a Pitch Input..trying codes on debugger with no luck like

(rate(Latitude) < -0.09 ) ? 1 : 0

worked..almost (falsehope) then discovered it has reversed effect when you turnaround from your startingSpawnpoint...boo!!.....
Or Gforce dont understand ..seems only detects ubrupt stops to make it negative no good if your moving slowly. Even GS no negative acceleration detected on debugger backwards is also positive not what i expect.. Im afraid my FunkyTree knowhow is very limited and cant figure this out also seem searching in forum was fruitless.Any one know how?

  • Log in to leave a comment
  • Profile image

    Use the code — ceil(-Pitch) and then the lights will only activate if your going backwards

    +1 2.0 years ago
  • Profile image
    2,790 OrderlyHippo

    I'll just leave this here. Cosine is a trig function. If you use cosine(AngleOfSlip), it will output a value from 0-1 depending on your direction of motion forwards, OR a value from 0-(-1) if you are moving backwards. The cosine function finds the perfect ratio between x and y that fit your angle, so if the angle is negative, that ration will be a negative #. You can also use the sign(x) to just give you 1 or -1 depending on if x is pos or neg. sign(cos(AngleOfSlip) will give 1 if moving forewards or -1 if moving backwards. A hurrah moment for me!

    +1 3.0 years ago
  • Profile image
    1,212 An2k

    @edensk
    @jamesPLANESii
    on debugger
    AngleOfSlip code moving backwards @ 1 kph = -179.99
    added ceil
    ceil(AngleOfSlip) and forward @ 1 kph= jumping from value of 0-1
    ceil(AngleOfSlip) and back @ 1 kph= jumping from -179 to 180
    ceil(AngleOfSlip) dead stop is all negative numbers

    watta Heck is AngleOfSlip a hidden variable hmm maybe ive have missed it somehow? BTW
    works for my needs THANK YOU ALL!!! you guys be credited when i publish my 1st submission

    you see im trying to use diagonal 4wheelsteering(on Yaw) hence the going backwards issue.. since forward is not a problem
    but going backwards lights will be incorrect therefore i should reverse it and needed a trigger code (going backwards) still having issue due to my lack of FT knowhow but the front andrear signal lights works

    (Front signal light wont lightupmwhen goin backwards.. only forward issue result not consistent but here it is)

    frontright
    ceil(AngleOfSlip) > 0 ? clamp(Roll, 0, 1) : 0

    frontleft
    ceil(AngleOfSlip) > 0 ? clamp(Roll, -1, 0) : 0

    (On going backwards even the pitch input is released Rearlight will still lightup until stop (min(sign not needed but left it)
    rearRight normal
    AngleOfSlip <-179 | min(sign(Pitch),0) | clamp(Roll, 0, 1)

    rearLeft normal
    AngleOfSlip <-179 | min(sign(Pitch),0) | clamp(Roll, -1, 0)

    Still having issues getting that diagonal 4 wheel steering signal lights on backwards ..since all i can do for code is If else lol ..but still i have a trigger now for backwards TY

    +3 4.6 years ago
  • Profile image
    16.5k edensk

    AngleOfSlip > 90
    The ternary selection is unnecessary.

    +1 4.6 years ago
  • Profile image

    It might be a kinda long code.... remind me to do it tomorrow (or about 10 hours time) @An2k

    4.6 years ago
  • Profile image
    1,212 An2k

    @jamesPLANESii on GForce() how to detect backward in code form? Been trying and seen no examples on crafts here...and you said when angle of slip >90° is backwards.. how to do that in Funkytree code? What variable should i put in for angle of slip?

    4.6 years ago
  • Profile image

    Gforce, 1 G (1x earth’s gravity) is 1 input. 10 Gs, generally the most fighter pilots experience when doing high speed, tight turns, that is 10x earth’s gravity.
    Accelerating and braking in a normal car, you generally only experience a maximum of 1 G of acceleration and braking when you completely floor it.
    So if you have a random rotator set to 90 degrees and have the input Gforce, when not accelerating, the rotator will rotate to 90 degrees. When experiencing 2 G, the rotator will rotate to 180 degrees, and experiencing 10 G, the rotator will rotate 900 degrees and so on.

    4.6 years ago
  • Profile image

    You can do stuff to make it tell if you’re moving forward or backward. Like, if your angle of slip is more than 90 degrees, you’re moving backward. Also acceleration is always positive because when you’re slowing down, you just speeding up backwards.

    +1 4.6 years ago
  • Profile image

    Haven’t taken physics yet be like

    4.6 years ago