Shooting enemy from one side only

What I mean is I am making a jungle adventure platform game and 1 of the bosses is a tiger but I want to make it so the player can only hurt the tiger it’s walking right away from the player so the player can only shoot the tiger in the back.
But I am struggling to find a way to implement this I thought of having a separate hitbox that is linked to the back of the tiger but can not find any way to do this.
I also tried to make the bullet only hurt the tiger if the sprite is flipped but this didn’t seem to work well enough.

This is the code that I have tried so far

Thanks for any help

Found out the code was working just fine it was just that the tiger was moving that quick that he flipped again before the bullet hit him.
Took me 4 hours to find out tried a ton of variables and different object settings to find out he was just a bit too quick.
Don’t I feel like an idiot.
At least I got there in the end.

2 Likes