So I have prefabs in my game that will spawn and be placed by the player if they push a GUI button. I’m trying to figure out how to set the individual buildings hit points though. So, if the player creates a barracks:A and then later creates a barracks:B and say barracks:A takes some damage, how would I adjust the damage amount for the individual, in-game spawned barracks? Is it as simple as attaching a script to it like building.cs and having it’s hit points inside of it adjusted under certain conditions? Will all buildings with the building.cs be effected if one is, or only the individual building? If there are any links that will explain how such scripting works I would appreciate it. I’ve managed to get a loose grip on how scripts can interact with each other but, of course, I’m still trying to figure several things out and the structure is proving to be difficult for me!
Is it as simple as attaching a script to it like building.cs and having it’s hit points inside of it adjusted under certain conditions? Will all buildings with the building.cs be effected if one is, or only the individual building?
Yes
Is it as simple as attaching a script to it like building.cs and having it’s hit points inside of it adjusted under certain conditions?
Yes, once you instantiate the prefab, if it already has the script, it’ll be also creating a new instance of the class, so you can get a pointer to it by using GetComponent on the game object instantiated.
Will all buildings with the building.cs be effected if one is, or only the individual building?
Only the individual one, as long as you handle it properly. But no way you can affect every instance. Unless you keep track of every instance and deliberately do that.