You can make it move away by testing it's X and Y coordinates.
(so if we say object 2 is the one that is running away)
If object 2's X is greater than object 1's X then move object 2 +1 pixel along it's X axis. (meaning it will run to the right if it's on the right hand side of object 1)
I'm sure you can work out the other directions from that
try that out davince. see if it works. it wont. lol.
it has to first look in the direction of what its running away from. otherwise its just gonna go back and forth.
at least im pretty sure. i will try it out but logically it shouldnt work.
n/a
DaVince This fool just HAD to have a custom rating
Registered 04/09/2004
Points 7998
22nd April, 2008 at 12:42:13 -
It shouldn't go back and forth... It should go the opposite way of the other object, because it isn't instructed to do anything else. If it doesn't behave like that it's a bug in MMF.
it still wont work correctly. it just means it will go the opposite of whatever direction you are going. if your facing up it will go down. but it wont run "away" from you.
if your facing up and the other guy is to your left you want him to run left away from you. not run/face down.
Distance = Square root ((X character - X object)^2 + (Y character - Y Object)^2)
--
Distance < 50 (can be changed depending on how close you want before running away
+ Flag 0 (Object B) = off
= Object B > Set direction to Direction("Object B") - 16
+ Object B > Set Flag 0 on
+ Object B > Start running away (+ speed up movement optional here)
Distance >= 200 (can be changed depending on how far away you want to be before the object stops running)
+ Flag 0 (Object B) = On
= Object B > Stop running away (+ return movement to normal speed)
+ Object B > Set flag 0 off
---
That's one way of doing it. for 8 directional movement
For 2 directional movement (i.e left right)
Try doing:
--
Distance < 50 (can be changed depending on how close you want before running away
+ Flag 0 (Object B) = off
+ X(Object A) > X(Object B)
= Object B > Set Direction to Left
+ Object B > Set Flag 0 on
+ Object B > Start running away (+ speed up movement optional here)
Then the same but with X Obj A < X obj B, and direction to right
Where Distance is now square root((X character - X Object)^2)
--
DaVince This fool just HAD to have a custom rating
Registered 04/09/2004
Points 7998
23rd April, 2008 at 04:06:57 -
Originally Posted by cecil try that out davince. see if it works. it wont. lol.
it has to first look in the direction of what its running away from. otherwise its just gonna go back and forth.
at least im pretty sure. i will try it out but logically it shouldnt work.
Actually, your code should do exactly the same as mine, as the result of both is "set direction to direction opposite of object 2's". If you want something more complicated...
davince i just thought of something else. if you run towards the other object it will make it run TOWARDS the character. it just doesnt work. you gotta have the two events.
i put yours into mmf and it does exactly that. its not running aaway its just running the opposite direction of the character (which in some instances is actually towards the player)
its logically flawed and its apperent when you do it in mmf.