Profile image

Chaser Lights with Funky Trees

66.7k SnoWFLakE0s  4.2 years ago

Bogdan posted this, calling it Pretty Lights... They indeed are pretty, aren't they?

These types of lights are typically known as chaser lights, and I organized a general formula that you can use in order to use them yourself. Note, this is slightly complex, so you will need to read through to use it yourself.


Here it is, in all its glory:

ceil(clamp(cos((360/a)*(Time - b)),c,1) - c)

The following is the explanation of some variables. You need to decide these in the order presented.

  • a is the cycle repeat interval, in seconds. e.g. if a = 4, then your chaser loop will repeat every 4 seconds.
  • b is the chaser light offset. This is a tad bit more complicated, it's a divided by the number of lights in your chaser loop. (a / n, n = number of lights)
  • c is the light toggle duration parameter. This is how long each light is on for. To obtain a value for c, use the following formula: cos((360/a)*(b/2)). You can roughly round it. Make sure to use degrees mode for your calculator.

That's not the end of it, though- when you set up your lights and input the code, you don't put in the same thing for every light. This is a bit hard to explain, so I'll give you an example first.

I'll use 5 lights with a 2 second repeat cycle. That means:

  • a = 2
  • n = 5
  • b = 0.4
  • c = cos((360/2)*(0.4/2)) = cos(180*0.2) = about 0.809

and if we input the found values into our code:
ceil(clamp(cos(180*(Time - 0.4)),0.809,1) - 0.809)

HOWEVER!!!

The setup is a bit more than just copypasting that code. Instead, for the first light in your setup, use the same formula, but without b. (0*b). For the second, use the same formula with b (1*b). For the third, use the same formula with 2b (2*b)... repeat until the last light. This allows for the correct offset to be made, making the smooth look.

For the sake of your convenience, I'll list all the code for this particular example.

  • Light 1: ceil(clamp(cos(180*(Time)),0.809,1) - 0.809)
  • Light 2: ceil(clamp(cos(180*(Time - 0.4)),0.809,1) - 0.809)
  • Light 3: ceil(clamp(cos(180*(Time - 0.8)),0.809,1) - 0.809)
  • Light 4: ceil(clamp(cos(180*(Time - 1.2)),0.809,1) - 0.809)
  • Light 5: ceil(clamp(cos(180*(Time - 1.6)),0.809,1) - 0.809)

This one that Bogdan uses the exact same code from the example I gave.


I hope that made sense. Any questions in the comments I will answer, but only if you are being specific.

For more Funky Trees resources, visit:

bit.ly/FunkyResources

  • Log in to leave a comment
  • Profile image

    Awesome code!

    is there any way to make the 5 lights throttle sensitive (the lights run with 0 throttle and speed up relative to the % of throttle)?

    1.3 years ago
  • Profile image
    11.2k Birdman9301

    @NATCH abs(clamp(Yaw, 0,1))

    2.6 years ago
  • Profile image
    152 NATCH

    Ahh guys anyone know how to invert a light beacon?

    Like for example they will separately activate depending on what direction the yaw will move

    Like i hold the yaw on left the left beacon light will activate, the same on the right side. Thank everyone who's going to respond

    2.6 years ago
  • Profile image
    105k Hedero

    It works great! Thanks for the help. I tried to read the funky trees instructions but they don't make a whole lot of sense lol.@SnoWFLakE0s

    3.6 years ago
  • Profile image
    66.7k SnoWFLakE0s

    @Hedero
    .
    I probably need more context, but here goes nothing:

    clamp(VTOL,-1,0) + Roll

    3.6 years ago
  • Profile image
    105k Hedero

    I have tried and tried but funky tree codes seem to surpass the limits of my knowledge. I wish I could understand them more to improve my aircraft's performance like BogdanX does. But for now, I guess I'll remain simple. I'm trying to figure out how to make flaperons without using two rotators. I can make a super simple code that allows roll and VTOL but the VTOL goes up and down. I only want VTOL to have a negative value, not a positive one. While also allowing the roll to move up and down. What would the code be for something like that?@SnoWFLakE0s

    3.6 years ago
  • Profile image
    11.5k shipster

    That’s unfortunate... @SnoWFLakE0s

    4.1 years ago
  • Profile image
    66.7k SnoWFLakE0s

    @shipster
    .
    No.

    4.1 years ago
  • Profile image
    11.5k shipster

    Is there a “distance from target” code? I’m trying to make a countdown to fire a weapon

    4.1 years ago
  • Profile image
    12.0k dINE

    @SnoWFLakE0s no problem

    4.2 years ago
  • Profile image
    66.7k SnoWFLakE0s

    @nadvgia
    .
    Fixed. Thanks.

    +1 4.2 years ago
  • Profile image
    12.0k dINE

    Link does not work

    4.2 years ago
  • Profile image

    @SnoWFLakE0s I just wanted to make AI to player (Its called Mech Neuralink)

    4.2 years ago
  • Profile image
    66.7k SnoWFLakE0s

    @BuiltBionixInd10
    .
    AI has nothing to do with this particular system. As for certain other types of systems, I have yet to test that.

    4.2 years ago
  • Profile image

    @SnoWFLakE0s does AI work or fit with funkytrees

    4.2 years ago
  • Profile image

    @SnoWFLakE0s does the AI know how to use funky trees

    4.2 years ago
  • Profile image
    66.7k SnoWFLakE0s

    @Stormfur
    .
    Probably is somewhere, although this the method I was sure was going to work 100%. I use what works. You have any other periodic functions that sinusoids? Not really...

    4.2 years ago
  • Profile image
    15.7k Stormfur

    Nice. But isn't there simpler ways to do that exact same function?

    4.2 years ago
  • Profile image
    7,325 WarringMunky

    @SnoWFLakE0s there was a story I think in the early or mid 90s where a hacker (who I think was the catalyst near-villian) named himself Snowflake as a joke about how nobody's unique and the only person who got the joke was the protagonist.

    4.2 years ago
  • Profile image
    66.7k SnoWFLakE0s

    @spefyjerbf
    .
    Definitely- I've also been thinking about the possibility of arcade games using a system like this.

    +1 4.2 years ago
  • Profile image
    66.7k SnoWFLakE0s

    @DickBrazen
    .
    Nah, it's an username I came up with many years ago, just out of randomness.

    +1 4.2 years ago
  • Profile image
    7,325 WarringMunky

    @SnoWFLakE0s is so full of learnings and is that a reference to The 'Net in your name (or some other '90s hacker movie or book)? Anyway, yah! I've tried to make chaser lights before and was only able to come up with a cheap alternative in my Flying Platform. Danke mucho!

    4.2 years ago
  • Profile image
    161k spefyjerbf

    Nice. I did something like this on the lighting of my most recent build too! It’s a fun way to make a design come alive.

    4.2 years ago
  • Profile image
    48.3k Sm10684

    Why are you big brain?

    +5 4.2 years ago