In my game, enemies are map sprites (events) that trigger a battle once interacted with. What I'm trying to do is make it so that, when an enemy touches you from behind, it triggers a surprise attack. Basically, I want a way to determine whether the player is facing an enemy or has his back to it. I'm using Galv event start types, but it doesn't have a notetag for whether you're facing the event or not.
MZ Event touches players back
RPG Maker MZ SupportYou can use control variables to get player direction and event direction, compare them and put conditional branch.
if $gamePlayer.direction() = $gameMap.event(ID).direction()
trigger surprise attack
trigger surprise attack
if $gamePlayer.direction() === $gameMap.event(this.eventId).direction()
Untested, but this should auto-update the ID.
There's still 2 mistakes. The whole if statement should be in () and also eventId is a method so after it also ()
Yeah, you're right.
if($gamePlayer.direction()===$gameMap.event(this.eventId()).direction()) { [stuff happens]}are you trying to make this pixel perfect or just grid/tile based?
Original thread: https://forums.rpgmakerweb.com/threads/event-touches-players-back.183756/