The Daily Click ::. Forums ::. Klik Coding Help ::. Chains?
 

Post Reply  Post Oekaki 
 

Posted By Message

Benny Lindberg



Registered
  08/11/2010
Points
  54
9th October, 2011 at 11:27:24 -

Hiya! I know I've found a tutorial for how to make a chain object thingie once. You know, where several parts are linked together dynamically. Does anyone know where I might find it, or know how to explain it?

 
n/a

nivram



Registered
  20/07/2006
Points
  171
9th October, 2011 at 16:27:19 -

Benny. I have more than one example of this on my website. Maybe one or more will help you.

Marv

 
458 MMF2 & CTF 2.5 examples and games

http://www.castles-of-britain.com/mmf2examples.htm

Benny Lindberg



Registered
  08/11/2010
Points
  54
9th October, 2011 at 16:43:58 -

Thanks a bunch, Marv!

 
n/a

Benny Lindberg



Registered
  08/11/2010
Points
  54
9th October, 2011 at 17:10:02 -

I found a good example there, but it didn't allow for "stretching" the links, any idea how I'd do that?
I don't quite understand the mathematics behind it .

 
n/a

Benny Lindberg



Registered
  08/11/2010
Points
  54
9th October, 2011 at 17:23:03 -

http://www.youtube.com/watch?v=oSkVZpTS17E Something like the arms of the boss at the end of this clip is what I'd need.

 
n/a

nivram



Registered
  20/07/2006
Points
  171
9th October, 2011 at 21:25:59 -

Sorry. I don't know how to do that, unless it is done by animation. Not too good at physics.

Marv

 
458 MMF2 & CTF 2.5 examples and games

http://www.castles-of-britain.com/mmf2examples.htm

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
9th October, 2011 at 21:41:51 -

Verlet Integration is a "relatively" easy way to do complicated looking physics chain effects. Its rather simple mathematics, which when put into X/Y coordinates for chains, makes a very bouncy, realistic looking chain. I have a very simple example under my profile, but you need to have a fair grasp of data structures and scoping to implement it well- you need to store the X/Y coordinates for each chain node and calculate for each one individually. It could be brute forced out a little easy if you hardcode each node as a separate type of active object, and just copy/paste the integration.

heres the wikipedia article on it, should be more helpful than me;

http://en.wikipedia.org/wiki/Verlet_integration

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Benny Lindberg



Registered
  08/11/2010
Points
  54
9th October, 2011 at 22:58:25 -

Alright, I'm going to give it a try, though it seems more powerful and complex than what I actually need.
I don't need real physics, I just need the links in the chain to keep together, and be attached at a stop and a start point.

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
9th October, 2011 at 23:31:54 -

Wait . . . . are you saying you don't need the chain to actually bend and that you really just need it to have an end and a beginning (kinda like the grapple in Super Metroid?)

If so, the formula is:

StartX + ((EndX-StartX)/Number of Links) * Link Position

StartY + ((EndY-StartY)/Number of Links) * Link Position

Link position can be achieved by just having a link object and spreading 1 into it.

This doesn't work well with a bunch of links, but will probably suffice for most occasions. I had it working using a bunch of links in the past by using floats IIRC, but I can't seem to get MMF to use them atm and I don't have much time, sorry.


 
n/a

Benny Lindberg



Registered
  08/11/2010
Points
  54
9th October, 2011 at 23:40:57 -

I'll try that thanks, seems like what I'm looking for!
Also, MMF can use floats if you have the floats stored as an alternable value in an object and you get the reference from there.

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
10th October, 2011 at 01:27:14 -

Another simple way to do it if if you want a slightly better looking chain but don't care about physics and its bounded at both ends at an absolute location (like in the video), is to have each node be positioned at exactly half the distance between the previous node is on the current frame, and where the next node is on the last frame. So for example;


Node 2 = (Node 1 + Node 3) / 2
Node 3 = (Node 2 + Node 4) / 2
Node 4 = (Node 3 + Node 5) / 2

For 5 nodes, where you already know 1 & 5


That will make the chain 'bend' a little bit as it swings, instead of being a straight line. Can be done all in 1 line of code

Edited by Pixelthief

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

nivram



Registered
  20/07/2006
Points
  171
10th October, 2011 at 03:22:48 -

Holy chain links Pixelthief! Any chance you would make an example from your last post?

Thanks

Marv

 
458 MMF2 & CTF 2.5 examples and games

http://www.castles-of-britain.com/mmf2examples.htm

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
10th October, 2011 at 03:32:57 -

sure, its pretty simple
http://sites.google.com/site/claniraq02/simplechain.mfa

Edited by Pixelthief

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

nivram



Registered
  20/07/2006
Points
  171
10th October, 2011 at 04:14:47 -

Thanks Pixelthief. Appreciated.

Marv

 
458 MMF2 & CTF 2.5 examples and games

http://www.castles-of-britain.com/mmf2examples.htm

Benny Lindberg



Registered
  08/11/2010
Points
  54
10th October, 2011 at 12:49:14 -

Looks awesome Thanks a whole bunch!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click