Basically, I'm trying to set up a set of stationary enemies that disappear when the player crosses a certain line. I imagine it has something to do with variables relating to the x coordinate on the map, but that's about it.
How to get player to trigger event when they cross a x-coordinate line?
RPG Maker VXAce SupportFirst, you need to make two variables: Player's X Coord and Player's Y Coord. Then make an event on the map (trigger: parallel process) with the following:
Control variables: Player's X Coord = Player's Map X
Control variables: Player's Y Coord = Player's Map Y
Then a conditional branch with whatever you need—for example, if you wanted the enemies to disappear when the player's X coordinate is greater than or equal to a number (let's say 10 in this example), then you'd go:
Conditional branch: Variable Player's X Coord > = 10 (make sure 'set handling when conditions don't apply' is ticked)
If you're making the enemies disappear with a switch, then you'd set that switch to ON here.
Else:
set the switch to OFF.
If you're wanting to also include the player's Y coordinate (for example, set something for when they're on a specific tile), then you'd include a conditional branch for that inside the conditional branch for the player's X coordinate and then have the switch inside the conditional branch for the Y coordinate.
Conditional branch: Variable Player's X Coord > = 10
Conditional branch: Variable Player's Y Coord > = 15
Set Switch ON
Else:
Set Switch OFF
Hope this makes sense! 🙂
Control variables: Player's X Coord = Player's Map X
Control variables: Player's Y Coord = Player's Map Y
Then a conditional branch with whatever you need—for example, if you wanted the enemies to disappear when the player's X coordinate is greater than or equal to a number (let's say 10 in this example), then you'd go:
Conditional branch: Variable Player's X Coord > = 10 (make sure 'set handling when conditions don't apply' is ticked)
If you're making the enemies disappear with a switch, then you'd set that switch to ON here.
Else:
set the switch to OFF.
If you're wanting to also include the player's Y coordinate (for example, set something for when they're on a specific tile), then you'd include a conditional branch for that inside the conditional branch for the player's X coordinate and then have the switch inside the conditional branch for the Y coordinate.
Conditional branch: Variable Player's X Coord > = 10
Conditional branch: Variable Player's Y Coord > = 15
Set Switch ON
Else:
Set Switch OFF
Hope this makes sense! 🙂
What @A-Moonless-Night said is correct so what I am writing doesn't change the fact that what has been said is correct. What I want to suggest is a way to avoid using 2 variables and a switch to trigger your event.
You can create the event with 3 pages:
Page 1: Parallel process
Page 2: Autorun, when Self Switch 'A' is ON
Page 3: Action Button, when Self Switch 'B' is ON (or any other self switch, read below)
In page 1 you can use the "Script" command and type this:
if ($game_player.x == number) #you can add more conditions here
$game_self_switches[[@map_id, @event_id, 'A']] = true
end
#number is the coordinate of your line.
Of course you can use $game_player.y instead of $game_player.x if you need a horizontal line instead of a vertical one.
In page 2 you can write your event as you please and then activate another switch (for example self switch 'B') to activate your event page 3 which is blank. If you don't want page 3 to be bank then change it to fit your needs.
Feel free to use the one you like the most.
You can create the event with 3 pages:
Page 1: Parallel process
Page 2: Autorun, when Self Switch 'A' is ON
Page 3: Action Button, when Self Switch 'B' is ON (or any other self switch, read below)
In page 1 you can use the "Script" command and type this:
if ($game_player.x == number) #you can add more conditions here
$game_self_switches[[@map_id, @event_id, 'A']] = true
end
#number is the coordinate of your line.
Of course you can use $game_player.y instead of $game_player.x if you need a horizontal line instead of a vertical one.
In page 2 you can write your event as you please and then activate another switch (for example self switch 'B') to activate your event page 3 which is blank. If you don't want page 3 to be bank then change it to fit your needs.
Feel free to use the one you like the most.
Thank you both very much.
Original thread: https://forums.rpgmakerweb.com/threads/how-to-get-player-to-trigger-event-when-they-cross-a-x-coordinate-line.70231/