I’m trying to create a mirror effect, so like a two-tile tall mirror that sits on a wall and reflects the player character’s movements. So I need the event to move in tandem with the player, except for the y-axis, where it will move opposite of the player. I know this likely involves some math with variables, but I can’t figure it out. Someone else made a thread about the same thing, but they didn’t explain how they ended up solving it. If anyone could please help with this, it would be greatly appreciated.
Having an event move contrary to the player on only one axis
RPG Maker 2000/2003 SupportI'm extremely new to rpgmaker(although I do have a small amount of block coding experience) and I don't have the same rpgmaker, so I could be wrong, but can't you use a looping conditional branch to set movement route of the event based on what button is pressed? For example, in the player clicks left, you can set the movement route to left, but if the player clicks down, you set the movement route to up.
This sounds flaky. I'd rather save old player coordinates and in a parallel process I'd check current player coordinates compared to old, move the event accordingly and then save current into old.
@Cherry’s solution is exactly how I figured it out. I couldn’t really put it into words, and wanted some possible answers to be in this thread in case someone else is trying to do the same thing.
It's pretty much the same river reflection logic in platform games:
The calculation is based on subtraction:
I'll try to rewrite the logic for the mirror in events and post it here.
Sorry for the delay, I tried to make some adjustments to improve the answer, I never have luck when using
I wanted to know, is this the concept you are planning?
The calculation is based on subtraction:
Y Reflection player = Y Pos player - Y Static mirrorI'll try to rewrite the logic for the mirror in events and post it here.
Sorry for the delay, I tried to make some adjustments to improve the answer, I never have luck when using
Loop and Break Loop, so I used Label.I wanted to know, is this the concept you are planning?
This is amazing! It’s exactly what I was looking for, thank you!
Watch part 1 to understand how to start the event.
Event:
Just to understand, this is a base, I didn't do a pre-initialization event to make the reflection start in a position relative to the player, I just did the part of following the new position.
Depending on how you use your reflex, you may be slower than the player.
Good lucky
Event:
Code:
@> Comment: ---------------------------------------------------------------
: : INIT - LIMIT FOR REFLECTION (MIRROR BOTTOM)
: : ---------------------------------------------------------------
@> Control Variables: [0033:MIRROR_LIMIT] = This Event's Y Coordinate
@> Comment: ---------------------------------------------------------------
: : LABEL - REFLECTION'S COORD
: : ---------------------------------------------------------------
@> Label: 1
@> Control Variables: [0034:X-Refle-Curr_Pos] = This Event's X Coordinate
@> Control Variables: [0035:Y-Refle-Curr_Pos] = This Event's Y Coordinate
@> Control Variables: [0031:X-Refle-New_Pos] = Player's X Coordinate
@> Control Variables: [0032:Y-Refle-New_Pos] = Variable [0033]
@> Control Variables: [0032:Y-Refle-New_Pos] *= 2
@> Control Variables: [0032:Y-Refle-New_Pos] += 1
@> Control Variables: [0032:Y-Refle-New_Pos] -= Player's Y Coordinate
@> Conditional Branch: Variable [0032:Y-Refle-New_Pos] > Variable [0033:MIRROR_LIMIT]
@> Control Variables: [0032:Y-Refle-New_Pos] = Player's Y Coordinate
@>
: Branch End
@> Comment: ---------------------------------------------------------------
: : MOVE REFLECTION
: : ---------------------------------------------------------------
@> Conditional Branch: Variable [0034:X-Refle-Curr_Pos] < Variable [0031:X-Refle-New_Pos]
@> Set Move Route: This Event (Skip), Move Right
@>
: Branch End
@> Conditional Branch: Variable [0034:X-Refle-Curr_Pos] > Variable [0031:X-Refle-New_Pos]
@> Set Move Route: This Event (Skip), Move Left
@>
: Branch End
@> Conditional Branch: Variable [0035:Y-Refle-Curr_Pos] < Variable [0032:Y-Refle-New_Pos]
@> Set Move Route: This Event (Skip), Move Down
@>
: Branch End
@> Conditional Branch: Variable [0035:Y-Refle-Curr_Pos] > Variable [0032:Y-Refle-New_Pos]
@> Set Move Route: This Event (Skip), Move Up
@>
: Branch End
@> Wait for All Movement
@> Conditional Branch: Player is facing Up
@> Set Move Route: This Event (Skip), Turn Down
@>
: Branch End
@> Conditional Branch: Player is facing Down
@> Set Move Route: This Event (Skip), Turn Up
@>
: Branch End
@> Wait for All Movement
@> Jump to Label: 1
Just to understand, this is a base, I didn't do a pre-initialization event to make the reflection start in a position relative to the player, I just did the part of following the new position.
Depending on how you use your reflex, you may be slower than the player.
Good lucky
I ended up getting excited and adjusting some details of the system, which in the future would allow creating reflections for NPCs, using event calls:
Regarding the other topic with the same subject, I believe that another OP is too new to understand what events are, that's why I didn't post there. You, on the other hand, are clearly experienced and might be interested in the Playlist I made of how I created the system, using it for study and perhaps creating something more practical and simple:
https://www.youtube.com/playlist?list=PLj0HSLYd4udG5F00_jS8HjJuYFGs7j2jhOriginal thread: https://forums.rpgmakerweb.com/threads/having-an-event-move-contrary-to-the-player-on-only-one-axis.167008/