Separating Objects on X axis

I have A character who have a shield to block enemies attack when need. When the shield is on either the bullet or any thing in collision is deleted or the enemy if in collision with the shield are separated from the shield. Now a drawback is, if the character is in the air above enemies had with the shield on and it moves(fly) down on their head, the shield pushes them from their heads against the platform and moves them down through the platform out of the screen (in easy word it penetrates through the platform). And the enemies are platformer characters. Either you tell me some cure or just tell me how to make computer separate it just on X axis…

NOT GOT the point, will you please add a screen shot of what is going wrong

Are you using “separate two object” ? If so, I recommend you to use other actions.

If you only want to move enemies on X axis, you can detect if the enemy is at the right side or at the left side of the player (position X). If he is at the left and is in collision with the shield, add a force to the left. If he is at the right side, move him to the right. You can use a timer to avoid multiple forces which depend of framerate.

This will look like :

What if the enemy is on the center

Is improbable that this happens, but you are right, set one of the two conditions to “<=” or “>=” :wink:

Thanks!