The Daily Click ::. Forums ::. Klik Coding Help ::. Run away
 

Post Reply  Post Oekaki 
 

Posted By Message

Fish20



Registered
  03/12/2007
Points
  263

VIP MemberPS3 OwnerI like Aliens!I'm a Storm TrooperIt's-a me, Mario!I am an April FoolPicture Me This Round 48 Winner!
21st April, 2008 at 17:47:34 -

how could you make an object run in the oppisite direction of another one?

 
All your base are in another castle, take this.

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
21st April, 2008 at 17:50:21 -

standard movement? some more words


 
Craps, I'm an old man!

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
21st April, 2008 at 17:59:09 -

ball movement with this event works

object 1 is the one running away
object 2 is the one being run from

+always
-look in direction of object 2
-set direction to Dir( "object 1" ) - 16

 
n/a

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
22nd April, 2008 at 10:45:14 -

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

 
.

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
22nd April, 2008 at 10:50:00 -

The 2 answers above are good answers above.

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
22nd April, 2008 at 11:11:50 -

it also depends what kind of movement youre looking for. top down? platform?

 
n/a

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
22nd April, 2008 at 11:43:15 -


Originally Posted by cecil
+always
-look in direction of object 2
-set direction to Dir( "object 1" ) - 16


Err...

+always
-set direction to Dir("object 2") - 16

That's one action less.

 
Old member (~2004-2007).

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
22nd April, 2008 at 12:04:23 -

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

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
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.

 
Old member (~2004-2007).

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
22nd April, 2008 at 13:03:36 -

i see. you changed it to object 2.

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.

 
n/a

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
22nd April, 2008 at 13:17:39 -

Object A = character
Object B = runaway object

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)
--



P.s. Yes, I do accept paypal payments.

Image Edited by the Author.

 
My signature is never too big!!!

Fish20



Registered
  03/12/2007
Points
  263

VIP MemberPS3 OwnerI like Aliens!I'm a Storm TrooperIt's-a me, Mario!I am an April FoolPicture Me This Round 48 Winner!
22nd April, 2008 at 17:48:10 -


Originally Posted by DaVince [Ectoprods]

Originally Posted by cecil
+always
-look in direction of object 2
-set direction to Dir( "object 1" ) - 16


Err...

+always
-set direction to Dir("object 2") - 16

That's one action less.



Davince's one didnt go anywhere because it kept changing back and forth forever.

 
All your base are in another castle, take this.

Fish20



Registered
  03/12/2007
Points
  263

VIP MemberPS3 OwnerI like Aliens!I'm a Storm TrooperIt's-a me, Mario!I am an April FoolPicture Me This Round 48 Winner!
22nd April, 2008 at 17:56:40 -

I tried cecil's and it worked. Thanks!

 
All your base are in another castle, take this.

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
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...

 
Old member (~2004-2007).

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
23rd April, 2008 at 05:08:53 -

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.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click