The Daily Click ::. Forums ::. Klik Coding Help ::. How can I make an effect of a chain like the example in the image?
 

Post Reply  Post Oekaki 
 

Posted By Message

Sergiocarp



Registered
  24/05/2009
Points
  294
5th August, 2009 at 03:26:37 -

Hi, I have a question about MMF.
How can I make an effect of a chain like the example in the image?

IMAGE EXAMPLE

Image

 
__________________________________

www.mmfzone.com (para miembros que hablen espaņol)*(for spanish members)

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
5th August, 2009 at 05:33:53 -

Think I know how this could be done
OK, first, imagine the head and origin point are the only objects to start

H O

H(ead) moves about while the O(rigin) stays still, give whatever movement path or system you want to the head.

Now, lets add a chain link.

H C O

Now, this chain link constantly attempts to get to the point between H and C, note i say 'tries to get to', not 'is positioned at'. You would have it's target destination always be the constantly updated middle point, andthe speedof it's movement should also be proportional to the distance from that point.

So, say, you could always have it move 10% closer to it's every frame sorta like
*Always
-set position x to (Xpos+((TargetX-Xpos)*0.9))
then repeat for Y

where target X would be (OriginX+((HeadX-OriginX)*0.5)) <- 0.5 denotes half the distance between the head and origin
in full it'd look like

-set position x to (Xpos+(((OriginX+((HeadX-OriginX)*0.5))-Xpos)*0.9))

with this, when the head moves about, this 1 chain piece will keep trying to move towards the center, if the head moves fast, the distance is large, the chain moves faster etc. But it always appears to lag behind.

Now, you repeat this with several more chain pieces, which are instead of trying to move to the mid point (0.5, as mentioned above) try to reach different distances, you simply change teh 0.5 in the line abovetowhatever distance you want, 1 being the head, 0 being the origin.

Now, this would give you basically a basic bezier curve, this is the basic effect you're looking for.

This is totally off the top of my head of course, but it seems to me like it should work, ill see if i can get an example workin.



 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
5th August, 2009 at 05:48:41 -

Right, well first edit is that the speed of the piece needs to be higher the closer to the head it is, else it just moves as a straight line.

 
n/a

Sergiocarp



Registered
  24/05/2009
Points
  294
5th August, 2009 at 05:55:19 -

Thank you. But would greatly appreciate an example (.mmf) because I do not speak or understand English very well, so it would be really grateful if you upload an example.

Very Thanks, and sorry for discomfort.


(sorry for my english too)

 
__________________________________

www.mmfzone.com (para miembros que hablen espaņol)*(for spanish members)

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
5th August, 2009 at 06:36:30 -

Aight, got a pretty close effect to what you want, take a look, written in MMF2dev:

http://www.mediafire.com/download.php?x0vhtmjt2y5

The code is a quick hack together and supports a single chain monster with 9 pieces + origin per frame.

To make it work with multiple chains you would need to add more looping(A recurring loop that loops through each chain and then each piece in that particular chain) and some dynamic speed and position additions to the inertia calculations. And it's a little late for me to get my head around that properly at the moment

Sorry if it's a bit wordy for you :< hope you understand the code.

 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
5th August, 2009 at 06:38:28 -

Although, If you only intend to have one in the frame, you should be able to simply copy paste it into your frame for it to work. Could work as an interesting boss

 
n/a

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
5th August, 2009 at 12:30:14 -

That's a nice example. It gives me an idea... I may modify it to my own use


 
n/a ...

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
5th August, 2009 at 13:32:17 -

That's really cool, but if the head doesn't move fast enough the chain looks perfectly straight.

 

  		
  		

Sergiocarp



Registered
  24/05/2009
Points
  294
5th August, 2009 at 18:32:27 -

Thank you very much man, I really apreciate your help "MrMcFlurry". Image

 
__________________________________

www.mmfzone.com (para miembros que hablen espaņol)*(for spanish members)

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
6th August, 2009 at 04:25:11 -


Originally Posted by OldManClayton
That's really cool, but if the head doesn't move fast enough the chain looks perfectly straight.



If you were to add a further multiple to teh speed (I have each pieces speed to be multiplied by it's position in the chain) if say, you doubled it all, it would further exponentialise (If that aint a word, I call copyright on it) the movement.

also, the event that slows down the inertia (it like, sets inertia to the inertia*0.8 in that example), if you change that value, the movement of the chain pieces becomes more 'bouncy', 0.9 would be a lot more bouncy for example, but i tried putting in a speed that reflected the example gif

 
n/a

Ski

TDC is my stress ball

Registered
  13/03/2005
Points
  10130

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!KlikCast HelperVIP MemberWii OwnerStrawberryPicture Me This Round 28 Winner!PS3 OwnerI am an April Fool
Candy Cane
6th August, 2009 at 09:40:07 -

Where's that Taco dude? I saw this effect used quite a lot in his game trailer.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click