Making things that damage the player

how do I make a object damage a player when they collide?
I’m currently making a game where a spaceship needs to dodge asteroids, but how can I make the player get damage when it collides with the asteroid?

Check these space shooter game examples:

1 Like

You might use Health points and damage extension.

  1. Set up the collision masks if you didn’t.
  2. Give SPACESHIP the Health behaviour.
  3. For simple health system, Set Damage Cooldown [0], Start Health [the number of allowed collisions], Maximum Health [0].
  4. In the event sheet:
SPACESHIP is in collision with ASTEROID

Apply 1 points of damage to SPACESHIP (Damage can be reduced by Shield: no, Armor: no).
[Add your collision actions]

SPACESHIP is dead

[Add your death actions]

1 Like

at first, Thanks because this already helps me out alot.
but how do i set up the collision masks?

The collision mask fits the size of your the first image used for the sprite by default. But if you want to change it, you can edit or create custom collision masks from within the object’s sprite editor.

2 Likes

Thank You both for all of this. :pray:
This was all really helpful for my game

2 Likes

I have antother problem with my game please help me

And another😭

I have a new problem with the health.:face_with_open_eyes_and_hand_over_mouth:

now if the spaceship gets damage my whole healthbar shows 3 gray hearts instead of 2 pink and 1 gray. How do I solve that?

Can you give us screenshots of HEART BAR object properties (double click on it from object list or from the canvas), and the releated events








Add Trigger Once with collision conditions.
for further information:

https://wiki.gdevelop.io/gdevelop5/all-features/advanced-conditions/

1 Like