How can an event jump to the old position?

Hello!

I'll give you an example so that it's easier to understand. My event is a dog. I can change his sleeping place at any time. After he has slept, he runs through the area. When I activate a switch, the dog automatically jumps back to its sleeping place. Depending on where I set up his sleeping place, he should also jump there.

I hope you understand what I mean. I would be very happy if someone helps me maybe with a script. I can't solve the problem by jumping to another event. The dogevent must remember the position of its sleeping place.
To remember an event's position:

Control Variables (Event Tab 1): Game Data -> Character -> choose this Event and Map X/Y.
You need 2 Variables; one for X and one for Y.


To relocate an event:

Set Event Location (Event Tab 2)
Choose your 2 variables

That's it!
Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/how-can-an-event-jump-to-the-old-position.171064/