The Daily Click ::. Forums ::. Klik Coding Help ::. Help doing a movement code in MMF2 please!
 

Post Reply  Post Oekaki 
 

Posted By Message

Mikeware



Registered
  19/02/2010
Points
  29
26th October, 2010 at 06:30:39 -

Hello every1, my first post ;D
im getting crazy trying to make something here on mmf, I tryed many ways possibles but none worked...
what am trying to do is make a single creature have their own "object_location" that moves and then after the movement the creature moves smoothly to the location, it works with just one creature but when I add another creature all messes up and don't work how it should..
here is the code, whats im doing wrong?
I'll post an image to make it faster:
Image

 
n/a

ffomega



Registered
  05/04/2005
Points
  216
26th October, 2010 at 13:49:14 -

I had a similar problem awhile ago with active objects. I'm not sure if the problem is legit or just my imagination, but I am making an application originally based on counters and active objects. The counters would affect how the objects wouldd behave and display....and everything seemed to work just fine but after so many active objects were placed within the frame....the events assigned to them no longer worked. I ended up having to make the active objects but have each object load images from outside the application instead and this solved my problem (so far). It seemed to me that the way I had coded the application, the more active objects I had the slower the app would run (I have dozens of active objects....each animation had 8 directions, each direction had about 60 frames). After so many placed it stopped using the behaviors I placed in them.

While I do not know what type of objects you're using, nor how many of them you are using at one time....I treated the active object like the active picture object. This may indeed have nothing whatsoever to do with your snippet of code though

 
n/a

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
26th October, 2010 at 15:24:25 -

I have looked shortly throught your code and it seems you do not select objects properly.

You should use a fastloop and spread value to loop through all the objects.

 
Code me a sausage!

Mikeware



Registered
  19/02/2010
Points
  29
27th October, 2010 at 00:06:54 -


Originally Posted by Don Luciano
I have looked shortly throught your code and it seems you do not select objects properly.

You should use a fastloop and spread value to loop through all the objects.



thanks for reply
how exacly should I do that?

in this code, with only 1 creature in the frame, it walks ok and everything works fine, but when I add another creature it starts the problems, the red squares walk at the same ways where in this case it should have his own 'AI' each one...

 
n/a

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
27th October, 2010 at 12:21:51 -

Like this:
on start of frame or whatever
unit Spread value 0 in value A

spread value and start loop must be separate events...

start loop "create"

on loop "create"
unit value A = loopindex "create"
unit flag 0 off?
-set unit flag 0 on
-create red block
-set red value A to fixed value of unit

With this you will attach both unit and red, so you can select them later when doing conditions and actions like shown below.

start loop "actions"

on loop "actions"
unit value A = loopindex "actions" - this selects unit
red value A = unit fixed value - this selects that unit's red
put any condition now you want
-and do actions

"

If you want always to check for creating new units then rename both loops into actions, otherwise you should put create loop into a group of events, cause it's not very good to have two loops running at the same time.

There is also a lot of articles about fastloops, you might read that to understand better what they do.

Edited by Don Luciano

 
Code me a sausage!

Mikeware



Registered
  19/02/2010
Points
  29
27th October, 2010 at 15:06:53 -


Originally Posted by Don Luciano
Like this:
on start of frame or whatever
unit Spread value 0 in value A

spread value and start loop must be separate events...

start loop "create"

on loop "create"
unit value A = loopindex "create"
unit flag 0 off?
-set unit flag 0 on
-create red block
-set red value A to fixed value of unit

With this you will attach both unit and red, so you can select them later when doing conditions and actions like shown below.

start loop "actions"

on loop "actions"
unit value A = loopindex "actions" - this selects unit
red value A = unit fixed value - this selects that unit's red
put any condition now you want
-and do actions

"

If you want always to check for creating new units then rename both loops into actions, otherwise you should put create loop into a group of events, cause it's not very good to have two loops running at the same time.

There is also a lot of articles about fastloops, you might read that to understand better what they do.


thanks again and this really seems to work from what i saw.. but u said it isn't good many loops running in the same time, im planning im doing a mmo so there ill be like 200+ creatures around the frame... I think this is going to get crazy haha
should it still work "okay" with those many loops?
or should I try a diferent way without loops? if it's even possible?

 
n/a

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
27th October, 2010 at 23:38:33 -

Depends mostly on how you code it, but 200+ objects shouldn't be a problem.

Try to have only one loop going at a time.
like always start loop "main" 200 times.

but you shouldn't have more than one loop running at the same time... like start loop "a" start loop "b", start loop "c"... etc, and loops that you need to run only once or not often should be in group a of events that you disable after the loop is done.

 
Code me a sausage!
   

Post Reply



 



Advertisement

Worth A Click