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?
You might use Health points and damage extension.
- Set up the collision masks if you didn’t.
- Give SPACESHIP the Health behaviour.
- For simple health system, Set Damage Cooldown [0], Start Health [the number of allowed collisions], Maximum Health [0].
- 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]
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.
Thank You both for all of this.
This was all really helpful for my game
I have a new problem with the health.
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/