damage

I’m creating my own game and I’ve this problem:
I have placed some spikes in the level. When the player touches one of the spikes, he should get damage. So far no problems. But I want that the character can’t be hurt for about 1 sec, so the player get’s a chance to get away from the spikes.
I thought you could do that with a delay sensor, but apperently that isn’t working.
Does anybody know how you can make this?

you could try an integer property and have it add up to a certain number before he takes damage. or an interval property. to me, integer properties make more sense.
I made it confusing didn’t I ._.

Well, It is clear, but it isn’t work.
I suppose it is my fault, that’s why I will now explain what I did:
Properties:
Hit Bool (False)
Timeout Int (0)

Property: Hit = False + --------
Touch: The Spikes -------- and ----------- Property: Toggle (Hit)

Property: Hit = True ------ and ----------- Property: Timeout (add +1)

Property: Timeout = 10 — and ---------- Property: Toggle (Hit)

I think that’ s it. Let me now if you find my mistake

I would do it with python and just use a timer.

I haven’t learned python, but if you would show me a script or tutorial which explains it.
That would be very nice.

Sorry delay is better.

Here is a blend file

Just use arrows to move. The cube is the spike. If you are more then a second there the Ipo plays.

Hope that helps

http://www.conspicuous.ch/blend_img/Spikes.blend

Your blenderfile works perfectley, that’s great,
but now I’m a little bit confused. I’m trying to workout how it works, but it is complicated for me.
If I got any questions about it, I will post them here.
Thank you anyway for posting it, it will probably solve my problem.

// edit
I’ve succesfully inserted the script in my game, but I’m still not getting it really. :S
I’m sure I’ll get it later.
Maybe another question: I wanted to make him flash as long as he’s hit.
Any idea how I could do that?

Hey nice to hear that it’s working. Just animate the alpha of your material and use the IPO actuator. If its not working just let me know I will make you a file example.

Another problem I ran into:
I wanted to make a menu, but apperently BGE doesn’t render text objects. Is there a way to make them render? Another way to solve this problem is using planes with UV textures, but Blender neither renders UV textures. Any idea how to solve this?

Loads of up-to-date BGE tutorials, including rendering text:

http://www.tutorialsforblender3d.com/Game_Engine/Tutorials_index.html

Ah, I’ve allready read that tutorial, but now I’ve seen I missed something.
Thanks for the tip.

And again a new problem:
When using textures in blender games, there is nothing of shadows and lightning.
How to add this?

This again has to do with the health.
It’s the first piece of python I’ve ever written, so it’s obvious that I might have made some mistakes:

import GameLogic
controller = GameLogic.getCurrentController()
owner = controller.getOwner()

if owner.Health == 6:
owner.setVisible(True)
else
owner.setVisible(False)

The problem is that when Health isn’t 6 it doesn’t make the object invisible. How to fix this?

For lighting make sure you change the draw type in 3D window to Textured (press D with the mouse in the 3D window and select from list) and that you’ve got Blender GLSL Materials enabled in the Game menu (and all the settings turned on). For realtime shadows use spotlights, or bake the shadows.

Your code works well if you have a not a “:” missing on the else. And tabed your text

But it is better to write it that way:

import GameLogic
Cont = GameLogic.getCurrentController()
Obj = Cont.owner



if Obj["Health"] == 6:
    Obj.setVisible(True)
else:
    Obj.setVisible(False)

Your code works well if you have a not a “:” missing on the else. And tabed your text

But it is better to write it that way:

import GameLogic
Cont = GameLogic.getCurrentController()
Obj = Cont.owner



if Obj["Health"] == 6:
    Obj.setVisible(True)
else:
    Obj.setVisible(False)

So to avoid depricated code

Thanks for the tips.
I’m not that familiar with python and it’s syntax, so I allready thought that would give me some problems.
I will try it out as soon as I can.

The code doesn’t work? Any idea how that may come?

For lighting make sure you change the draw type in 3D window to Textured (press D with the mouse in the 3D window and select from list) and that you’ve got Blender GLSL Materials enabled in the Game menu (and all the settings turned on). For realtime shadows use spotlights, or bake the shadows.

When I use GLSL, the texture images are no longer transparent.
How do I solve that?