Ai health damage basic brick and object setup

Hi,

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?

here for upbge 0.2.5 should also work in any other blender version aslong as you manually create the blend exactly as this blend file is.

kill enemies or player the right way.blend (510.9 KB)

You can change the endobject brick with scene brick and call the next level or a game over scene.

I used a video tutorial years ago which showed the example I tried, and you viewed and noted it had a missing brick, and it turned out not to work.

And if i remember correctly, i remade that file and added healthbars with it. So you had an working example. Anyway the file i created in above post works and can be used / altered to you liking.

I learned the idea file from Arsenal rl youtube channel, that was where I got my info from. I don’t recall you making an example file about this, why would i need one if there was a video. That was where I learnt most of the brick stuff, the games failed because they needed python code which you helped me out three years ago with.

I found this old video on the video site, so this is how you make a basic AI using cubes, which then one collides with another, and it is removed or health counter lowers. I thought about that add an object that acts as a trigger to that event.