Make enemy untargetable after it dies

Hello,

After a boss is dead I don’t want it to collide with my players bullets anymore, but still remain on screen. How can I do this? Thanks.

Try giving the boss a variable “Alive” that is “yes” when he’s alive and “no” when dead. Then, add a condition to the bullets hitting/damaging the boss that it can only cause that damage when the variable “Alive” is “yes”.

2 Likes

I suppose it means to turn off the contact with the objects of the “bullet” and they went right through?
I think you need to disable certain behaviors due to which the collision occurs.

Hi, ‘collision’ is a condition based on which an action (e.g. reducing healthpoints) happens. @beanmatt’s suggestion to use variables is probbaly the most straightforward way to do what @LloydNebulon wants to achieve.

If the physics engine is involved, then such bullets will collide, regardless of the condition. In this case, you must turn it off.

From previous posts of @LloydNebulon I assume that he is working on a space shooter without physics and even if that would be the case he would still need to use variables for what he wants to do.
Edit: Well he could simply turn physics off after the boss is dead.

1 Like

What condition or action would I need to check if boss is still alive. Having trouble…

Hi, just to give a slightly different approach than @beanmatt has suggested.

You could also compare directly the health points - if you have something like that - of your boss.

BThe condition would be something like: if the object variable “alive” of boss = “yes”.

But, you’d have to make sure it was initially set to “yes” and then once the boss dies set it to “no”

Right, but what command in the drop down do I chose to make that happen? Sorry I’m still learning gdevelop.

Would this still allow the player bullet to collide with the boss? I want the bullets to just go right through, if the boss is dead.

Yes, in the first condition the bullet is deleted after collision. In the second there is nothing like that so the bullets are just passing the boss/enemy sprite.

Which change the text function are you using for playerhealth to change? Modify text?

Yes, it is this here:
Capture

In your example, who is the player? Is that the boss or the player?

I forgot to change that for the example here, playerhealth should be actually enemyhealth.

Could you post that picture of how you set up enemyhealth at the beginning of the scene again? I’m like still in kindergarden with coding.

When I choose modify text, it asks for an object, which object am I suppose to choose? It says none are available? This is just getting too confusing.

The text object is what you modify by displaying the value of the variable (or whatever text you want to display).
Capture