I’m having trouble with a very common problem in making games and other such things. (allthough maybe not so often specifically like this)
I want to be able to make instances of objects and get Blender or Python to create sepperate properties for each instance when the game begins.
My game is a shoot-em-up where the enemys loose energy if a ray (comming from the bullet) hits the body of the enemy. In other words they dont loose energy if they are hit by a bullet, but rather if the bullet is going to hit them. This is a much beter way of doing things, because if I used the Collision Sensor in the enemy to detect the bullet, there is a big chance that the bullet would just pass through the mesh of the enemy (because of the high speed of the bullet, and because blender only registers collisions every frame).
So this is how it is set up:
The Logic Brics in the bullet look roughly like this:
RAY (property: enemy) >> and >> MESSAGE (loose energy)
The Logic Brics in the enemy look roughly like this:
MESSAGE (loose energy) >> and >> PROPERTY (energy, -1)
This works fine for one enemy.
The problem occurs when I make instances of the enemy. (I want to able to just position emtys where an enemy should appear). When I hit one enemy, they all loose energy! This is because they share the same energy property.
The soluition would be to maybe have a python script that creates sepperate Properties for each instance of the enemy. But there would still be problems regarding the message sensor and actuator, because even if you had a python script that made sepperate properties for each instance and i set up the logic brics in the bullet like this,
[RAY (property: enemy1) >> and >> MESSAGE (enemy1 loose energy)
RAY (property: enemy2) >> and >> MESSAGE (enemy2 loose energy)
and so on…]
there would still be problems in the enemys Logic Brics. How would they now know wich message to recieve?
This is driving me round the bend. I don’t know python, just logic brics.
First of all, I just want to know whether this is at all possible to solve, and secondly, how would one go about it?
Thanks, and regards, Monkeyboi