## [Solved] Event running away from player

Started by Globock, May 25, 2013, 10:38:50 am

#### Globock

##### May 25, 2013, 10:38:50 amLast Edit: May 25, 2013, 02:07:46 pm by Globock
So I've been trying to make animals running away from player (as they're scared), but I had a little trouble. Here is how I made it:

I'm sure it's not that hard, I just had a looong break from RMXP ^^' Can anyone solve it?

#### Zexion

##### May 25, 2013, 11:55:26 am #1
I don't know exactly how you want this to work. Do you want it to move away from the player if they are stepped on, or if the player is within a certain range? If in a range, than what is the range

#### KK20

##### May 25, 2013, 12:24:35 pm #2
In your picture, the first conditional branch says the following: If Event's X-coordinate is less than or equal to 4, perform movement. I believe you forgot to subtract the player's X with the event's X. Also, you would have to either find the absolute value of that result or square it accordingly.

 Other Projects RPG Maker XP Ace Upgrade RMXP to RMVXA performance! XPA Tilemap Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

#### Globock

##### May 25, 2013, 12:31:27 pm #3
Yes, I want event to run away when at certain distance, but how exactly should I make it? I have a little trouble

#### Zexion

##### May 25, 2013, 01:06:55 pm #4
Here you go.
Spoiler: Show

Takes 5 Variables though lol.

Basically just make the distance formula sqrt( (x2-x1)^2 + (y2-y1)^2).
Then some conditional branches to make sure it only moves when requirements are met (always check the handle...blah box)
You can change the range if you'd like currently it's at 2 squares just change that number in the conditional branches.

Thanks alot!