Object facing another object

im making a fruit ninja type game, and im trying to make it if the player faces an specific object and slashes, that the object dissapears, see screenshots, right now, with both scenarios the object dissapears when slashed

function If Touch or left mouse button is down, Change the animation of Player to Slash
(i couldnt paste 2 screenshots so i converted it to text)

Need more info. Are you using the horizontal flip for the character to switch sides? Are you checking collision between the character and object, or distance?

yes i have it if the player presses D, the sprite flips horizontally to the left side, and vice a versa for A,

distance, if player and block (the thing that needs to break when slashed), are less than 500 pixels away, and if the player is facing the block (which is what i need help with), the block should dissapear

There are several ways that you could do it.

  1. Based on the angle difference. You could check the AngleToObject. Let’s sayBy default the angle to the right should be 0, and to the left 180 (you’d need to confirm if that’s the case in your setup). Then do the checks you are doing, e.g. Is flipped = no, and distance < 500, and AngleToObject < 90, then the box will be cut only if it’s on the right, and you are facing right. And then the other side: Is flipped = yes, and distance < 500, and AngleToObject > 90.
  2. Or, you could attach two invisible objects to the main character that will act as the detection. Place one object on the left of the character, and one on the right. If the right object is in collision with the box, and flipped = no, then the box on the right is cut. If the left object is in collision with the box, and flipped = yes, then the box on the left is cut. You wouldn’t need the distance check anymore.

All the parameters are just examples, you’d need to adjust them to your implementation.