I was wondering if someone could give me some insight on an idea. I’ve got a tank model and when the health reaches “0” I would like to have the turret go flying off to show “death” of said tank.
Would I need to set a separate tank model up in a different scene and have it trigger at “0” to replace mesh with one that is animated?
Second question I have been thinking about for the day was, When the crosshairs point at the object I would like to have the health displayed on screen. I’m assuming I could use a ray for this but am unsure how to go about setting it up.
If at all possible I would like to achieve this using logic blocks as I don’t know python…yet.
for the first question , the best things to me is change obj ,
when the tank is “death” destroy the tank, and add those new obj (rigid body) at the same time
for a tank 2 new obj i think can be right
i have make this demo, only with brick
when click with mouse the tank “explode”
you can notice which the mesh of “tank death” was originally the same mesh just a bit deformed
the collision must be accurate to have a good effect , so ,must be collision enabled with triangle mesh or convex hull (in the physic panel) for new obj
you must put this in a hidden layer (which is just a layer not active, not visible ) in order to call it
For the Ray thing you could do a mouse over. if you use your mouse to move your gun. or you could insted of a ray use a realy long invisable cilinder, and have the tank display its life when it is hit by it. or here is the code you would use for the ray.
Cont = GameLogic.getCurrentController()
hit = Cont.getSensor("Ray").getHitObject()
if hasattr(hit,"Life"):
setattr(hit,"Life",True)
Make sure you name your ray sensor " Ray " and add a bool property named Life to each tank.
@Kylona: Thank you very much for the cylinder idea, I love it! Since I’m not using the mouse to look or aim that seems like it would be perfect for what I’m trying to achieve.
@Kylona that api is very old. I think cont.sensors exists in 2.49, and so it should be used to make migrating easier. (it may not be, it’s been a while!)