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

Post Reply  Post Oekaki 
 

Posted By Message

Zi-Xiao



Registered
  29/07/2002
Points
  537

VIP Member
9th November, 2006 at 14:52:38 -

I've got 100 object A and 100 object B. I want object B to run away (look in the opposite direction) from object A if it gets too close. Here's my reasoning so far:

Every 1 second
- Spread 0 in ID B
- Start fastloop "loop1" (number of object B) times

on loop "loop1"
- Spread 0 in ID A
- Start fastloop "loop2" (number of object A) times

on loop2
+ A ID = loop index "loop2"
+ B ID = loop index "loop1"
+ distance between A and B (calculated using advance direction object) is close
- Set B direction to look away from A
- Stop loop "loop2"

Not working. Both loops are executed but the evaluation in loop2 isn't working for some reason. Not sure if it's my reasoning or an mmf quirk. This is mmf1.5 btw.

I toyed around with creating big active objects around all object As and having object Bs bouncing off of them but that would be inefficient.

Zi-Xiao

 
n/a

Fifth

Quadruped

Registered
  07/05/2003
Points
  5815

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
9th November, 2006 at 15:22:36 -

Alright...

First of all, you don't want to spread the value and start the fastloop on the same event. That's pretty much a guarantee that nothing'll work.

Second, you can also get it to work without the second loop. Instead, set Object B's value to the distance from the object A that's being tested, then have another event in the same loop to test if any object B has its value below the given distance.

So it'd be like this:
Image

 
Go Moon!

Aptennap



Registered
  23/04/2004
Points
  916
9th November, 2006 at 15:24:39 -

-distance between A and B (calculated using advance direction object) is close
-pick object B
+set direction to dir A - 32
Doesn't something like this work?

 
Oh sweet mary.

Aptennap



Registered
  23/04/2004
Points
  916
9th November, 2006 at 15:24:49 -

-distance between A and B (calculated using advance direction object) is close
-pick object B
+set direction B to dir A - 32
Doesn't something like this work?

 
Oh sweet mary.

Aptennap



Registered
  23/04/2004
Points
  916
9th November, 2006 at 15:25:07 -

-distance between A and B (calculated using advance direction object) is close
-pick object B
+set direction B to dir A - 32
Doesn't something like this work?

 
Oh sweet mary.

Zi-Xiao



Registered
  29/07/2002
Points
  537

VIP Member
9th November, 2006 at 15:53:36 -

Damn; tripple post anyone? Anyway, your method worked, Fith thanks alot. I also appreciate the nicely presented graphic .

Zi-Xiao

 
n/a

Aptennap



Registered
  23/04/2004
Points
  916
9th November, 2006 at 17:50:55 -

I'm really sorry for the triple post, dont know how that came.

 
Oh sweet mary.
   

Post Reply



 



Advertisement

Worth A Click