Second part of my Air to Air Guided Missile Building Guide.
Introduction to Triton Aerospace Air to Air Guidance Code
This is part 2 of the guide on how to build guided air to air missiles in Juno: New Origins using Triton Aerospace's air to air missile code. In this section, we will be learning about all the different parts of the missile's vizzy code, as well as what needs to be tuned and how.
As a reminder, the missile vizzy code can be found here.
Note: if you are using my code, the missile code will look slightly different but mostly performs the same (just less organized and optimized since usually only i use it)
The Code
Upon opening the vizzy program (A.K.A Flight Program) for your missile's command part, you should see this:
If you do, you have the right code! Feel free to zoom out. Looks overwhelming, right? It is at first, but we can bite it down into easier to chew pieces.
Step 1: Loadout
This code is the first part of the missile code that gets activated. It is activated when the launching jet fighter sends a broadcast to craft named LoadOut; this is the jet communicating to all listening missile's, that will then talk back to the missile, giving its identity back to the launching jet, so it can sort out what weapons it has onboard.
The missile's identity, which is its IDName, is made up of two parts:
◆ The command parts ID, which separates it from other missiles of the same model.
◆ The name of the command part, which should include the designation of the missile. This tells the fighter jet what model the missile is. Different weapons networks have different compatible models. For Triton Aerospace's Type 1 Air FCM, these are the AAM1, AAM2, AAM3, AAM4, and AAM5. If you are using one of Triton Aerospace's jets or his FCM, your missile's command part must be named one of these. Otherwise, it will be incompatible with his network and it will not work.
It then sends the IDName back to the jet by broadcasting "IDs" to craft, which the jet's Type 1 Air FCM will pick up and sort.
Step 2: TargetingData
Gets Target ID from the Launching Jet's FCM, which will be used later to define the missile's target.
WARNING: You must always select a target before firing the missile. Otherwise the missile will malfunction.
Step 3: Launch
Whenever a jet with Triton Aerospace's FCM has selected a weapon model and pressed launch, the first missile in the list will get selected as Launch Weapon in the FCM code (not visible). A broadcast "Launch" to craft will be made to all missiles with the IDName of the first missile on the list. All missiles will check the IDName and their own identity. Because every missile's identity is unique, there will only be one missile that has a matching identity to the broadcasts IDName data, which fulfills the if statement.
What occurs afterwards is the Missile Launch Sequence (MLS) and is made up of a few parts:
◆ Set Throttle to 100%: Sets the missile's throttle to 100%, useful for Air to air missiles that can throttle their engines.
◆ Set Activation Group 1 to True: Activates the side interstage or detacher of the missile, causing it to be pushed away from the jet. From this point on, the missile is completely guided on its own.
(Wait 0.3 Seconds)
◆ Set Activation Group 2 to True: Activates the motor/engine of the missile, causing it to propel itself forward.
◆ Set Variable Target to PreTarget: Sets the pretarget given to the missile by the Type 1 Air FCM as its official designated target, which the guidance computer will get useful data about to help guide itself towards.
(Wait 0.6 seconds)
◆ Broadcast Active: Activates the Guidance computer and parts of the missile's fusing system. At this point, your missile is now actively maneuvering on its own towards the target.
(Wait 1 Seconds)
◆ Set Activation Group 3 to True: Activates the rest of the missile's fuse.
Alternative to Step 3: Jettison
The Jettison code has the exact same filter as the Launch code, except this time it only detaches the missile, and DOES NOT activate it. The missile will free fall on its own and its journey ends when it eventually get destroyed by impacting something, usually the ground or the water. Yes, we drop explosive ordinances like that, what's wrong with it? Oh...
Step 4: The Guidance Code
This big chunk of code is the guidance code. It is a combination of variables that act as gains in the guidance computer, ZEM (Zero Effort Miss) program that calculates useful target data, and the control section, which turns that useful target data into actual control inputs that guide the missile to its target.
You can see that the ZEM and Control Section are also marked with "Do Not Touch". As stated, do not touch these codes. The actual gains and variables you need to tune are actually above the while true loop, circled in red, and it is what we will look at later on in the guide.
Note
Custom Expressions for Guidance
Step 5: Fuses (Proximity & Failsafe Fuse)
The Proximity Fuse and Failsafe fuse are built to ensure that the missile explodes at the right time, when it is as close to the target as possible.
The first element of the code gets the distance between the missile and the target between two intervals of time (ProxOld and ProxNew). This is built for the Failsafe fuse to use later on.
Below it is the time slow-motion feature. If the missile is very close to the target, often times it is travelling very fast, sometimes too fast for the game to react properly and detonate the fuse on time. As such, we want to slow down time when we get very close so that the game has enough time to read the code, perform calculations, and activate the fuse when needed.
Next up is the actual proximity fuse. Proximity fuses work by measuring the distance to the target. It then compares the distance to the target to Proximity_Fuse set in meters. The variable Proximity_Fuse tells the missile at what distance from the target it should blow up. When the distance to the target becomes less than that of the proximity fuse, it tells the missile that its within range of doing critical damage, and thus, the missile blows itself up. This means that there is a greater "bubble" around the target where the missile can do meaningful damage; that bubble being the proximity fuse value you put into the variable.
Note: you should only put a proximity fuse thats as powerful as your warhead can handle. Putting a large proximity fuse is useless if your warhead has weak explosive power.
Finally, there is the Failsafe fuse. It is called the Failsafe because it blows up the missile in case the missile is within close range, but misses the target too far from proximity fuse to activate. This destroys the missile, leaving a small chance of damage to the target while also ensuring that an active missile isnt flying around the battlefield or that it crashes into an area populated with friendly forces or civilians.
Step 5²: Impact Fuse
Most small, Hyper maneuverable missiles intended for ultra close range combat are designed to perform 180°s in order to hit their target, and for that reason, often do not have failsafe fuse or even proximity fuse. Instead, they use what is called "Impact Fuse", to determine if or if not the missile has impacted the target, and when the missile comes in contact with something once the fuse is armed, the missile explodes. Unfortunately, there is no way to determine that the target absolutely hit a part on the target, so instead, we have to draw an assumption that if the missile is within a certain distance to the target, the odds are that it did hit the target. If it hit something while being far from the target, it most likely did not hit the target and it missed.
Tuning the Guidance Computer
All the variables circled within the red line are the parts of the flight computer you must tune. We will go over each one and how you should tune it.
◆ Missile_Name: The missile's name and/or designation that is shown in the data of the missile's flight logs. I'd recommend keeping this close to or the same as the command part's name.
◆ Actuation Gain: Actuation Gain is a magnitude change of how hard your missile will pull to hit the target. It is less precise than tweaking Minimum N and Maximum N, so you have to do it carefully, often in steps of 0.1 or so. Actuation Gain CANNOT be less than 1, and should not be more than 2. If it is, your missile needs a design change.
◆ Minimum N and Maximum N: N determines how hard the missile pulls when at distance; the number goes down the closer you get. It is a number that is clamped between Minimum N and Maximum N, which are gains you set. At max range and farther, Maximum N is used to maintain control inputs at long range. Below Max range, N is scaled down from Maximum N until it reaches Minimum N, a floor.
If your missile is overcorrecting or overreacting at close range, your Minimum N may be too high. If it is not turning enough at close ranges, you may need to raise Minimum N. Likewise, at long range, if your missile oscillates, wobbles, or overcorrects, your Maximum N may be too high and needs to be lowered. Maximum N being too low isnt very common, but it can happen. If your missile isnt pulling enough in its loft, coast, or transition to terminal guidance, your Maximum N may need to be increased.
Helpful Tip: Minimum N will generally be in the single digits to double digits. Maximum N will generally be in the double digits, even into triple digits sometimes. If you are needing to scale the variables by wild amounts, you may need to change your Actuation Gain or missile design.
◆ Proximity_Fuse: the distance from the target, measured in meters, where the missile is deemed close enough to deal critical damage and automatically blows up. The distance where the missile deals critical damage is up for you to find.
◆ MaxRange: the maximum range, measured in meters, that the missile can travel and still hit the target, up for you to find. You should come up with a cutoff speed, in m/s, where you believe the missile is likely to no longer hit the target. When your missile reaches that speed, after the amount of distance it has travelled under its own power, that is your range.
Max range is also when the N variable scales down from Maximum N. When the missile is farther from the target than the max range, N caps at Maximum N, its ceiling.
◆ TerminalHoming: time, in seconds, from impacting the target where the missile stops lofting completely and actively pursues to intercept the target. The lower it is, the less time the missile has to change its course and intercept the target and the longer it lofts and vice versa. Generally, I use 10 seconds terminal homing for my missiles to ensure they dont overshoot.
◆ MaxCeiling: variable used in the lofting calculation to determine how high your missile is allowed to loft (fly above the target to reduce drag and increase range).
The number in the middle (marked in yellow) and to the right (marked in teal) matter most, they are the clamped range of how high your missile is allowed to loft. The middle number should generally be zero. The number to the right determines the maximum height your missile can loft to.
Helpful Tip: If you are wondering what the number on the left is (marked in red), it is a fraction. It is the initial distance between the misisle and the target (InitialRange) divided by a number. You can tweak the number if you choose to. The smaller the number, the more aggressive the loft will be. The larger it is, the less aggressive the loft will be.
Tweak, Test, and Repeat!
Now that you know what each of these variables are and how to tweak them, it is time to see how your missile flies towards a designated target. If you are using Triton Aerospace's Type 1 Air FCM, which you need to for this code, plug it into your jet, bind the according Activation groups to your jet's primary part. Then save your missile as a subassembly, and drag it and drop it somewhere on your plane where it is clear of obstruction. Alternatively, you can use Triton Aerospace's F-8B fighter jet. Launch the missile either against a target in the air or on the ground, making sure to select the target first, then select the missile you want to use.
Helpful Tip: You may be surprised but either air or ground targets work perfectly fine as the Air to Air guidance code, minus the proximity fuse, works great for air to ground missiles too! Guidance is all the same!
If you notice any instability, such as wobbliness, oscillation, doesnt perform as intended, or the missile misses, you should go back to the designer and alter the gains using the directions above (refer to Tuning the Guidance Computer) until it flies flawlessly.










