Profile image

More Funkytrees Questions

3,763 ThatKindaWeeb  3.5 years ago

So I found this phalanx CWIS style auto turret (forgot the creators name) and the funkytrees inside it

This is for the auto turret rotation

(((TargetHeading - Heading) + (rate(TargetHeading) * (TargetDistance / 1500)))/ 180) * clamp01(TargetDistance < 5000) * clamp01(TargetDistance > 1)

Turret Elevation
inverselerp(0,90,TargetElevation + (rate(TargetElevation) * (TargetDistance / 1500)))

Question(s)
•What parts of this control the turret leading the target?
•Is all this just verbal calculus?
•Where do I change the orientation of the cannon?
•Is this as complex as it looks?

I would REALLY appreciate if I could get some info on how in the hell these things work

  • Log in to leave a comment
  • Profile image
    29.9k Nerfaddict

    so here's what I can get from this.
    I'm seeing the word "Heading" used a lot, so this bit of code is for controlling the gun along the sideways axis.
    onto the numbers now.
    |
    I guess we'll start with the piece of code saying
    "(TargetDistance / 1500)))/ 180)".
    |
    the number 1500 is the muzzle velocity of the gun that this code is optimized for
    (but this can be changed if needed, just make sure the number in the code and the gun are the same).
    |
    the number 180 is the rotational range that this code is built for (then again changeable, and just make sure they line up).
    |
    now the next bit of code:
    * clamp01(TargetDistance < 5000) * clamp01(TargetDistance > 1)
    |
    this code activates the previous bits of code when the target comes within the specified ranges, in this case, as close as 1 meter and as far as 5km.
    |
    now I'd like to note that this is really only one half of the code. Preferably, I'd like to see the other half of the code: the one that controls the up and down movement.

    Pinned 3.5 years ago
  • Profile image

    Also, for anybody who can, I'd like it if you describe each section as it's own part.

    Pinned 3.5 years ago
  • Profile image

    @Nerfaddict you got it

    +1 3.5 years ago
  • Profile image

    @t0mato72 thanks, I suck at algebra so I guess that's a problem lol

    +1 3.5 years ago