Every if Statement gets called regardless of which object is the Mounted Turret.
I have also tried using if(buildPoint.mountedTurret = fixedTurret.gameObject) and if(buildPoint.mountedTurret.Equals(“HomingTurret(Clone)”)) etc.
Is valid, but then nothing is being called. I’m not sure why, as I can instantiate them with the names fixedTurret, homingTurret, scanningTurret, but for some reason it doesn’t seem that I can access them here.
What he’s saying there is that all 3 were being called because you were assigning them in each if statement, you weren’t asking if they were true or not. Now you’ve changed it you know none of them are being called. So instead you want to do a Debug.Log to see what IS being called. In the script type:
if(buildPoint.mountedTurret.tag == "SomeTagName")
// Do something cool!!!
is actually referring to. What is fixedTurret? Is it a gameObject? A string? A tag? A script? Normally people compare objects not by ‘is this the exact same instance of an object?’, but by asking ‘is this object of this type?’. You could give each turret a unique tag, which denotes their type, and see if by comparing tags, they’re the same.
So you’d assign the fixed turret the tag ‘FixedTurret’, or something like that, then check in script whether the object has that type of tag: