Collision poblems


#1

I programmed a game where an entity has lives. But even if an projectile hits my character the “lives” counter doesn’t go down. What exactly did I do wrong?
Lives


#2

Hi David,

can you share the link to scene with us so we can have a look?

Thanks


#3

How exactly can I send a link of my space? I’m asking because I already tried it before and it didn’t work.


#4

When you open a space, in the upper right hand corner there is the “Share” button. When you click on it, a direct link to the space will be generated which you then can post here.

share


#5

No Share
I don’t have this option. Is this because I use the Edu version with my class?


#6

Are you using a student account David? The share feature should otherwise be available…


#7

#8

Hi David,

you should define event listener like this at the very beginning of your program, so that they get set in the beginning before other code gets executed. Put the whole code block in the very beginning of your script and then it should work.

Also, I think you only need one onCollision listener for the man instead for all three spears. So something like this is everything you need I guess (you can also use or operator instead of multiple else if):

05

But then you need to put the logic where you check if lives === 0 inside this block, you can put it in a function and call this function then.