Hi, all!
So throughout my game project whenever I want to do damage to an object I have been having the object that gets hit call the function do damage itself on itself. For instance, when an enemy fires, it takes its ‘damage’ variable and plugs it into the bullet. The player gets the ‘damage’ variable from the bullet and applies it to itself.
Well, what if I wanted to damage everything onscreen?
One way would be to run a for loop through all of the children of my ‘enemy’ empty parent object,
But what about using the messaging system?
I have seen others use it, but have never found any practical use of it for myself. When I was programming games with Blender, I used messaging all of the time, but that was simply because it allowed me to not code much (a messaging system was supported in their ‘GameLogic’ UI ).
Currently, in my project, I have a BUNCH of ‘cahching this object’s script in the start’ and ‘using that variable when I need to’. Code can get really cluttered, as some gameObject have to be cached all of the time if I need to access them. I understand that this is not necessary with Messaging.
So…
- When should I be using the messaging system?
- How should I use it? (this can be simple)
- When should I avoid using it and opt for other methods for calling functions on GameObjects?
Thanks! - YA