Ai health damage basic brick and object setup


So as can be seen here, I made this last week, but it doesn’t work, not sure where I’ve gone wrong, but this basic setup should result in both objects receiving some damage, as there is a health counter as seen.

What am I missing?

I haven’t setup a brick program in a few years, I looked to some of my files, but they have python code, so the original brick setup I tried I don’t have.

put cubes hp on 0 you see it works. it will then become -1 etc

the property brick is wrong connected, connect it to a game brick where you quit game or set next scene

So you mean 0 instead of -1, I tried for both, no change. The property with 200 as integer is okay, I would guess.

I did try a scene for the enemy cube, so once down to 0 is should load a scene or restart. The health counter doesn’t work at all. Never mind any scene brick added to the enemy cube.

set the property brick to greater then 0

add a new property brick with less then 1 → and → scene change or quit game etc.

Do not forget on collision you remove the health of the cube running those bricks, not from the enemy

I tried this new attempt, I think what you stated is correct with what I have here. Collision must be for the cube which is enemy property variable.

And cube.001 is the enemy 2 property.

I tried both the name of the cube and the property, nothing changes.

1 Like

you can’t remove health from cube 2 if the bricks are on cube 1, that does not work at all. If you want cube 1 to damage cube 2 then you need to use the message brick.

with messages: cube 1 damages cube 2

#on cube 1:
collision -> and -> message(send)

#on cube 2:
message(receive) -> and -> property(add health -1) (remove hp)
property (hp less then 0) -> and -> edit object(end object)

without message damage cube 1 if hitting cube 2

#on cube 1
collision(cube 2) -> and -> property(add health -1)
property(health less then 0) -> and -> edit object(end object)

If I understand what you’ve typed there, damage brick and message are included on cube 2, or enemyhealth2 as I named it in the property menu.

Included the connected bricks with property and end object. I’ve clearly not done it correctly. No change.

oops with property brick instread of assign use add, my bad sorry.

The file above didn’t work. Damage brick on the left, and property on the right. Damage on enemy2 cube as a property, d there as you can see. May be it needs another damage on property message on the right?