As the title says, I want to spawn objects with a instance variable (health) and then subtract from it when my bullet collides with them. No matter what I do, the object always delete off spawn (when variable equals 0 they get deleted) or when i make them not delete when object variable equals 0 they dont take any damage. Not sure if im supposed to set the object variable to 50 when i spawn em or at the start of the scene
Set the object variable after you’ve created the object. If you want to default the object variable, then set it in the scene editor - in case you don’t know how to do that, here’s an example from another thread:
Your variable name will be different and the value set to a number, but you get the idea.
So this is what I have right now, I did what you said and added the object variable but for some reason the enemy’s are getting destroyed instantly. The “bullets” are the vegetables and they have a physics behaviour (if that matters or not)
Sorry if this a dumb question, just putting my game to a halt atm. Also i have the collision with the vegatables and enemy twice as I was messing around to see if MAYBE it worked or something
You have the object variable name health in quotation marks. The variable name shouldn’t have quotes around it.
It worked! Thank you, your a lifesaver!