Profile image

How to make weapons activate in range

90.0k winterro  1.6 years ago

So I built a few planes that shoot automatic cannons, but i need a code so the cannon only automaticly fires in a ten degree radius to the front, (like the lock circle of missles)

Does someone know how to do an activation code like this?

  • Log in to leave a comment
  • Profile image
    90.0k winterro

    @Kendog84 Got it!

    +1 1.4 years ago
  • Profile image
    25.1k Kendog84

    @winterro
    Via the "X" icon right above the connection icon. (Not the one at the bottom, that's variable setter)
    This icon (pic)
    When you name this TatorA, for example, now the word "TatorA" equals the angle of this rotator in XML/Funky Tree.
    So you can write activationGroup FT like "TatorA > 50"


    Some things to note:
    -You can't use numbers (1,2,3...) at the beginning of the name
    -As long as it's different from other xml attributes, you can name it however you like (but shorter the better)
    -Don't give the same name to more than one part (FT can break if you do)


    -I find it easier to make adjustment when I have the rotator range set to 100, and change actual range by changing the input value (input multiplier)

    If you want to know the exact angle of the rotator, you can create a label (cockpit interior part) that says {X} (replace X with your variable name).
    Here's an example that uses this if you need one (link)
    *You must first create the part variable. If you create a label first then create the variable, label won't work.

    +1 1.4 years ago
  • Profile image
    90.0k winterro

    @Kendog84 how to name rotators?

    +1 1.4 years ago
  • Profile image
    25.1k Kendog84

    @winterro
    Glad to help, you're welcome

    1.4 years ago
  • Profile image
    90.0k winterro

    @Kendog84 ah thx

    +1 1.4 years ago
  • Profile image
    25.1k Kendog84

    If you're talking about some kind of auto aim cannon on a rotator, you can use rotator's current angle variable.
    Name them TatorA and TatorB or something, and replace cannon's activation group with something like:
    abs(TatorA) < 10 & abs(TatorB) < 10

    1.4 years ago
  • Profile image
    13.1k Grob0s0VBRa

    (abs(TargetElevation-PitchAngle) + abs(TargetHeading-Heading) ) less than 10
    Try this, insert it in activation group of cannon part.

    +1 1.6 years ago
  • Profile image
    3,323 JustWingIt

    Hey winterro, do u remember a really cringe user named autumnus? Or something like that? Bc he's actually my little brother. Fun fact. Not sure about the code though, hopefully you'll find someone who can answer your question

    +1 1.6 years ago
  • Profile image
    83.5k ReinMcDeer

    I'm not sure what the code would look like, but maybe something like x>(heading - targetheading) and then the same for elevation?

    +2 1.6 years ago