MZ Moving an event or the player by a certain amount of pixels

I was experimenting with an plugin to cause the player to bounce away from an onMap enemy like you know it from SNES or Gameboy Zelda Titles.

I used $gamePlayer._x to alternate the position of the sprite which actually worked, but it let me bounce into walls and if you enter a float value to just bounce a quarter tile for example the player controller seems not to know where he currently is and you are not able to walk any longer.

Anyone got an idea how to alternate position without getting stuck between tiles? Maybe there is even an plugin that i just didn't found to do the trick
It would be helpful if you showed your event that wasn't working, we could offer help.

If I change $gamePlayer._x and then change it back (to make the player bounce then go back), it moves perfectly fine afterward.
Yes, you are right. Sadly i don't want to bounce back, i just want to bounce away when the player is hit by enemy or the enemy is hit by the player.

Moving the player or event by an integer number doesn't lead to any issues, but when i add for example $gamePlayer._x += 0.2 the player gets stuck between two fields and isn't able to move anylonger.

Original thread: https://forums.rpgmakerweb.com/threads/moving-an-event-or-the-player-by-a-certain-amount-of-pixels.161508/