hit and destroy enemy like mario style



image1 and image 2 is my grow up powerup.

While my character is normal in height, if the enemy AI hits it from the side, my character dies. If i hit it from above, I kill it. However, when I get the Grow Up power up, even if I don’t jump directly, the enemy AI’s die when I hit them.




these blueprints are in my character blueprint. i dont know how to calculate this. after i solve this i want to make if the character hits the enemy from the side while he is at normal height, he will die, but if he gets the Grow Power Up and hits the enemy, he will return to normal size.



thank you for your helps.

Great question and I would like to carry you one step forward in your game if I can.

Generally this logic possibly failing when you grow up capsules. Component’s world location is always from the capsule’s center.

As general check function logic: depending on height is not the best approach however you can compare.

let us know if you can fix it or not

heyy. thank you so much. this logic works pretty well. In addition to what you sent, I used get component bounds instead of get player location because I wanted to compare the head and the foot. After that, I calculated the invulnerability. This prevented my character from hitting an enemy and then bouncing while having the grow power up, from instantly hitting the enemy again and killing him. When my character gets the grow powerup, if it hits from the side, it does not take damage for 3 seconds. Everything is working fine now. çok sağ ol hocam :smiley:



Happy to hear that is solved. I know that you are learning things and its totally find to do things in traditional pattern, however would like to carry you one more step further without confusing you with additional design patterns or approaches.

Try to encapsulate logic gates between gameplay contexts.

A function to make mario big or small
A function to check if target is under foot
A function to check if target on side.

So you can always call same functions and your coding becomes more readable and extendable.

Another thing for you I think can be usefull is Enum Variable Type. You can create a blueprint enum from

You can create states like this for mario

and you can ask marios state to do various things like below

so you have more organised way of detecting states and what needs to happen.

There is further mechanics that can be crafted and player state, state trees or gameplay ability system, however enums would be a good match for you to learn basics.

Iyi calismalar :slight_smile:

1 Like