Open Andrew2070 opened 1 week ago
The code for MakeMissileArray
where the NullReferenceException
(NRE) happened is at https://github.com/BrettRyland/BDArmory/blob/master/BDArmory/Weapons/Missiles/MultiMissileLauncher.cs#L634.
There are only a couple of points in that code that could cause such an exception.
launchTransformName
doesn't match the launch transform in the model, which would cause this exception on the line
int missileNum = launchTransform.childCount;
since launchTransform
would be null
in that case.
string launcherName = launchTransform.GetChild(i).name;
will fail (though according to Unity documentation, it should give a different kind of exception, so it shouldn't be this). Looking at the way this is set up, those child transforms also have to be labelled in a specific way in the model for them to be assigned correctly in the code, i.e., they must be 7-character strings followed by an index (starting at 1), e.g., the BDA-E cluster missile uses missile1
, ..., missile8
.
Thanks! I had to revise the model in blender to incorporate the "rails" transforms, and name/number them accordingly. It loads into the game, attaches, and flies! So made some progress there, still working on getting the warheads to spawn correctly inside, and to deploy appropriately when at the right altitude.
I still am running into a few issues. I don't know how to get the warheads to deploy at say 50km. The missile will hit the ground and bounce off, while not releasing the MIRVS.
I just want to know is it possible for the submunitions to GPS guide themselves to the GPS target originally set for the parent missile? Are submunitions detectable on radar and interceptable by a SAM in guard mode? Can sub munitions have nuke modules to detonate in a nuclear fashion?
Parent Missile:
PART
{
// General parameters
name = BulavaMIRV-N
module = Part
author = CustomAuthor
// Asset parameters
MODEL
{
model = SMI_MissilesLaunchers/Parts/BulavaSLBM/bulavaN // Adjust path if necessary
scale = 1.0, 1.0, 1.0
}
rescaleFactor = 1
buoyancy = 1
NODE
{
name = Node1
transform = Node1
size = 0
method = FIXED_JOINT
}
// Editor parameters
TechRequired = precisionEngineering
entryCost = 12100
cost = 50000
category = none
subcategory = 0
title = Modified Bulava Missile with MIRV Submunitions
manufacturer = Custom Armory
description = A modified Bulava missile designed to deploy multiple MIRV submunitions guided by GPS coordinates at high altitude.
attachRules = 1,0,0,0,0
// Standard part parameters
mass = 4
dragModelType = default
maximum_drag = 0.1
minimum_drag = 0.1
angularDrag = 2
crashTolerance = 5
maxTemp = 5600
// Missile Launcher Module
MODULE
{
name = MissileLauncher
shortName = BSLCBM-N-MIRV
thrust = 600
cruiseThrust = 300
dropTime = 0.05
boostTime = 20.0
cruiseTime = 1440
guidanceActive = true
maxTurnRateDPS = 28
BallisticAngle = 45
DetonateAtMinimumDistance = True
decoupleSpeed = 8
decoupleForward = true
optimumAirspeed = 900
missileType = missile
homingType = AGMBallistic
targetingType = gps
rotationTransformName = rotationTransform
maxAoA = 25
aero = true
liftArea = 0.5
steerMult = 150
maxTorque = 1000
terminalGuidanceType = radar
terminalGuidanceDistance = 10000
activeRadarRange = 9000
maxOffBoresight = 100
lockedSensorFOV = 6
radarLOAL = true
BallisticOverShootFactor = 0.5
boosterMass = 1.25
boosterDecoupleSpeed = 7
decoupleBoosters = true
boostTransformName = BoosterTransform
boostExhaustTransformName = boostTransform
exhaustPrefabPath = BDArmory/Models/exhaust/smallExhaust
boostExhaustPrefabPath = BDArmory/Models/exhaust/largeExhaust
audioClipPath = BDArmory/Sounds/rocketLoop
boostClipPath = BDArmory/Sounds/rocketLoop
minStaticLaunchRange = 10000
maxStaticLaunchRange = 100000
engageAir = false
engageMissile = false
engageGround = true
engageSLW = false
}
// Multi Missile Launcher Module for Deploying Submunitions
MODULE
{
name = MultiMissileLauncher
launchTransformName = rails // Specify your transform name if applicable
subMunitionName = thermoMIRVsub // Reference the existing MIRV part
subMunitionPath = NKD/parts/Thermonuclear MIRV/mirvscaled // Adjust path if necessary
salvoSize = 28 // Number of submunitions to deploy per fire command
isClusterMissile = true // Defines it as a cluster missile
isMultiLauncher = false
useSymCounterpart = false
overrideReferenceTransform = true
tntMass = 475000000
offset = 0
rippleRPM = 10000
}
}
ThermoMirv (Sub Munition)
PART
{
// General parameters
name = thermoMIRVsub
module = Part
author = Harpwner (modified by CustomAuthor)
// Asset parameters
mesh = mirvscaled.mu // This should be the correct path and file name for your scaled model
rescaleFactor = 1 // Assuming the model was already scaled in Blender
// Node definitions removed to hide the part and avoid attachment issues
// (comment out if not needed)
// Editor parameters
TechRequired = Unresearcheable
TechHidden = True
entryCost = 0
cost = 0
category = none
subcategory = 0
title = Hidden ThermoMIRV Scaled
manufacturer = North Kerbin Dynamics (modified)
description = A hidden version of the ThermoNuclear MIRV scaled for use in clusters.
// Attachment rules (kept hidden for submunition behavior)
attachRules = 1,1,0,0,0
// Standard part parameters
mass = 0.35 // Adjusted for scaled mass if necessary
dragModelType = default
maximum_drag = 0.01
minimum_drag = 0.01
angularDrag = 1
crashTolerance = 5
maxTemp = 3600 // Adjusted maxTemp if required
// Missile Launcher Module
MODULE
{
name = MissileLauncher
shortName = ScaledThermoMIRV
thrust = 0 // Adjusted based on scaling
cruiseThrust = 0
dropTime = 1
boostTime = 0
cruiseTime = 80
guidanceActive = true
blastRadius = 70000 // Original value retained
blastPower = 70000 // Original value retained
maxTurnRateDPS = 15
missileType = bomb
targetingType = gps
homingType = AGMBallistic
optimumAirspeed = 1000
aero = true
liftArea = 0.02 // Adjusted for scaling
steerMult = 0.2 // Adjusted for scaling
maxTorque = 45 // Adjusted for scaling
}
// BDExplosivePart and other modules retained with original values
MODULE
{
name = BDExplosivePart
tntMass = 475000000 // Original value retained
explModelPath = NKD/effects/Explosion_Megaton
explSoundPath = BDArmory/Sounds/explode1
}
MODULE
{
name = BDModuleNuke
thermalRadius = 4000 // Original value retained
yield = 2500 // Original value retained
fluence = 5.0 // Original value retained
isEMP = true
reportingName = Scaled Warhead
flashModelPath = BDArmory/Models/explosion/nuke/nukeFlash
shockModelPath = BDArmory/Models/explosion/nuke/nukeShock
blastModelPath = BDArmory/Models/explosion/nuke/nukeBlast
plumeModelPath = BDArmory/Models/explosion/nuke/nukePlume
debrisModelPath = BDArmory/Models/explosion/nuke/nukeScatter
blastSoundPath = BDArmory/Models/explosion/nuke/nukeBoom
}
MODULE
{
name = ModuleShockwave
explosiveYield = 12000000000 // Original value retained
particleSize = 500 // Original value retained
}
MODULE
{
name = BDACategoryModule
}
}
Screenshots of both models in blender, the thermomirv is simulated to show it in there, it is not to scale, for some reason the original which was 1/3 the size, was scaled down 1/6 in game, so i doubled it to try to fix it, left it in there just to show you. it is surrounded by rails or empty "transforms" which are the spawn points for the 4x7=28 MIRVS.
Sorry for all the responses, I thought it would better organize the materials.
Here is a module the original bulava missile (parent) had:
MODULE
{
name = ClusterBomb
deployAltitude = 50000
deployDelay = 1
submunitionMaxSpeed = 1200
swapCollidersOnDeploy = true
subExplModelPath = BDArmory/Models/explosion/explosion
subExplSoundPath = BDArmory/Sounds/subExplode
}
This worked succesfully, but I could not emulate the nuclear effects of the sub munitions deployed, and I can't keep this module in there with MultiMissileLauncher, or else the game will crash. But, when this module was there, the fairings would deploy and the submunitions would release.
Ok. ClusterBomb and MultiMissilelauncher aren't really compatible.
Clusterbomb will take a number of child sub-models and eject them as submunitions, which will deploy at the set altitude and faull, unguided, to detonate on impact with something in a standard HE explosion; they do not have EMP/shapedCharge/Nuclear support. Cluster submunitions will not show up on radar/be interceptable bu point defenses.
MultiMissileLauncher will spawn one submunition per launchTransform present on the model, no need for a child mesh present on the model; submunition scale is set by whatever the scale of the submunition is (in terms of unity export) and the rescaleFactor = x.x value in the .cfg. MML submunitions are fully actualized 'missiles' in their own right, and capable of guiding themselves to a target using a specified guidance type and mode(so in the case of GPS will inherit the parent GPS coords), and support standard/rod/shaped/emp/custom/nuke warheads. For a deployment at x height above the ground you'd want to add a clusterMissileTriggerDist = 50000
line to the MultiMissileLauncher node in the .cfg, though this will only take effect if there's a target it's firing at, won't work if bombarding empty terrain. MML submunitions will show up on radar and can be engaged/shot down by point defenses.
MML fairing deploy requires the the fairings on the parent missile have transforms named "fairing"; they will eject automatically on submunition launch. Submunition launchTransforms also need to be named 'missile1', 'missile2', etc, not missile1A.
You also shouldn't have both a BDExposivePart module and a BDModuleNuke module, you only need the latter, though your thermalRadius = 4000 will limit that 2.5mT warhead to a 4km blastRadius
Hi SuicidalInsanity,
Thank you for your valuable feedback!
With your suggestions, I restructured the model and correctly implemented the clusterMissileTriggerDist code. However, after testing, I encountered two additional issues that have not been addressed. Even after fixing them, the original problem persists. I wanted to share my findings and tests to get more insight from you.
Issues Encountered: Bulava Missile: Part CFG: I realized I hadn't declared fairingTransformName = fairing, which I’ve now corrected. Model: I noticed that I also didn’t have a missileTransform, which I identified after examining the source code. After successfully implementing these changes, the problem was not resolved. To further investigate, I decided to modify the original ClusterMissile to test if my approach could be theoretically accomplished.
Testing with the ClusterMissile: 1) I modified the ClusterMissile from AAM/Radar to AGMBallistic/GPS. 2) I also updated the missile (submunition) to support AGMBallistic/GPS and added the nuclear module. 3) I test-fired it with both a terrain GPS target and a vessel GPS target. Results: 1) Against Terrain: Submunitions were not released, even when the GPS target was valid. 2) Against Vessel: Submunitions were successfully released, and the nuclear module (along with its effects and explosion) was triggered as expected.
I’m still trying to understand: 1) Why my fairings won't deploy, and why the submunitions aren't released, instead of which parent Bulava duplicates. 2) Why the submunitions don't release when targeting terrain, but they work fine when targeting a vessel.
I look forward to hearing your thoughts on this and whether I might have missed any necessary steps.
Thanks in advance for your help!
Screenshots:
Hi.
Basically, SMI Armory/Mod adds ballistic missiles, such as the Bulava missile, it has two variants, standard and cluster.
I am trying to modify the cluster munition to work like a multiMissileLauncher as BDArmory has done so elsewhere (a GPS guided missile that deploys submunitions that are radar guided themselves).
So I cloned the original bulava cluster missile, then added that respective module to it, and referenced an existing warhead (thermonuclear MIRV / thermoMIRV).
The game would then crash on trying to load the part out in SPH.
So, I discovered that the ClusterBomb module was the root of this issue. I removed it.
Now I can spawn the cloned/modified missile into the game, but it lacks an attachment node, which is weird because the node configuration is identical to the original file. It throws this error:
[EXC 22:47:03.426] NullReferenceException: Object reference not set to an instance of an object BDArmory.Weapons.Missiles.MultiMissileLauncher.MakeMissileArray () (at:0)
BDArmory.Weapons.Missiles.MultiMissileLauncher.Start () (at :0)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
This is the code in the part file for the cloned Bulava missile. As you can see I have referenced the thermoMirv part from the NKD mod. MODULE { name = MultiMissileLauncher launchTransformName = rotationTransform subMunitionName = thermoMIRV // Reference the existing MIRV part subMunitionPath = NKD/parts/Thermonuclear MIRV/model // Adjust path if necessary salvoSize = 8 // Number of submunitions to deploy per fire command isClusterMissile = true // Defines it as a cluster missile isMultiLauncher = false useSymCounterpart = false overrideReferenceTransform = true tntMass = 1 offset = 1 rippleRPM = 10000 }
I don't know what the issue here is. Can you explain it for me?
Is there a way to make custom multiMissileLaunchers? If so, what am I doing wrong here?