Move two objects away from player

Hi forum,


I want to make two objects (an impassable boulder, and it's passable shadow) move at the same time, so they feel like the same object, when the player push at the boulder. 


If I set both objects to move away from the player, they will move in different directions. I haven't managed to find a solution for this, but suspect a script may be a solution. Does anyone have good way for how to do this?
No, a script is not neccessary - but you'll need to calculate which direction to move to instead of using the simple "move away".


When the event is triggered, determine the player position and the direction to move to (either by conditional branches with player facing if the player needs to face the boulder to make it move, or with four variables for X and Y of both event and player if the player can move it by standing next to it).


Then use two set move routes (one for the event, one remotely for the shadow) to move both parts into the same direction.
Thanks! Always nice when it's easier than you thought!
The following will let you do it without conditional branches or variables:

Code:
Set Movement Route: (select boulder) (no wait)
                  : Script: this.moveStraight($gamePlayer.direction());
Set Movement Route: (select shadow) (wait)
                  : Script: this.moveStraight($gamePlayer.direction());



Makes both the boulder and the shadow move in the same direction the player is facing - assuming the player has to be facing the boulder to make it move.

Original thread: https://forums.rpgmakerweb.com/threads/move-two-objects-away-from-player.62834/