The Daily Click ::. Forums ::. Klik Coding Help ::. Flexible arm thingy
 

Post Reply  Post Oekaki 
 

Posted By Message

Ecstazy



Registered
  04/01/2002
Points
  179

VIP Member
31st December, 2008 at 14:20:42 -

Hello, once again I have a question for you.
I'm trying to make this mechanical arm attached to a wall that follows the player, the mechanical arm is made out of 5 base pieces and a pincer in the end, and the first piece is attached to one spot on the wall.
I think the main problem is keeping all the pieces connected together, and I'm a bit confused on how to pull it off. I set an active spot on where one piece connects to the next, and I guess it requires altering the angle of each object.
The thing is that I'm also trying to make it snake-like, so that it will be flexible and if the arm goes and up and then down, only the front will go down and pull the rest, instead of everything moving in the same direction like a single piece of metal.

 
Amongst Strangers
http://www.create-games.com/project.asp?id=1445

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
31st December, 2008 at 17:35:02 -

http://www.create-games.com/article.asp?id=1866

You were kind of vague about what you wanted.

 
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
31st December, 2008 at 17:46:55 -

think of each piece as a long rectangle, and put the action spot & hot spot at alternate ends, like this:


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

X A H X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



Now, in the events, do this:

Always: Put Arm#5 at Action(0,0) of Arm#4
Always: Put Arm#4 at Action(0,0) of Arm#3
......

etc

Give each object either an angle or 32 directions animation, and then at gameplay, rotate ALL OF THEM towards the player, at slowing speeds. For example, if Arm#5 was the closest one to the body of the enemy, and Arm#1 was the "fist", then do this:

Always: Rotate Arm#5 towards Player(0,0) at speed 3
Always: Rotate Arm#4 towards Player(0,0) at speed 6
....
Always: Rotate Arm#1 towards Player(0,0) at speed 15


You can do this via the Direction Calculator extension, available at the clickteam extension archive. Now thats assuming you use the 'animation directions' approach. If you want to do it via angles, you can use the "Angle Calculator" extension, which should work like a charm.


Basically each piece is tied to the previous piece at a joint, and rotates from there.


Edited by Pixelthief

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

Ecstazy



Registered
  04/01/2002
Points
  179

VIP Member
2nd January, 2009 at 00:34:11 -

Thanks for the help guys!

Pixelthief: Your idea seems to work...more or less. The problem is that I can't find a way to keep the arm attached to the wall. If I link the objects the way you said, I get something like a snake that crawls after the player, and if I do the opposite everything stays still and only rotates.
I tried limiting the condition with something like: Distance between ArmUnit5 (the one attached to the wall) and ArmPincer (the "fist") smaller than 250px (the distance between those 2 pieces if the arm is completely stretched) AND the position of the piece attached to the wall is certain X and Y values.

I'm also not sure what you mean by having them rotate at a certain speed. I ended up using angles, and the only idea I had in mind is giving all objects ball movement in different speeds (which kind of works I guess).

Here's what I have so far, without various failed attemps:
http://solid.flam.free.fr/blah/mech_arm_code.png
As it is I have a snake-like creature floating after the player while the piece connected to the wall stays there all alone.
(I used a different object that I had already in the frame to calculate the angle between 2 objects and added the "look at" events to get the pieces moving. I then realized only the first one was enough)


Sketchy: Sorry about the vague question, I wasn't sure how to explain it. I guess I could've said it's a tentacle-like movement.
I read the article, it was pretty interesting and I understood the whole curves subject, but I'm not really sure how to put it into code. Also it seems that with my 6 pieces arm it's a REALLY long expression (the 4 points code was messy enough), it seems somewhat inefficient.

 
Amongst Strangers
http://www.create-games.com/project.asp?id=1445

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
2nd January, 2009 at 18:31:04 -

A few things seem "wrong" with that, to me.

Firstly, the event order - it should probably go more like;

1.) rotate section 1 towards player,
2.) position section 2 at 0,0 from section 1's action point,
3.) rotate section 2 towards player,
4.) position section 3 at 0,0 from section 2's action point...

Secondly, all the segments instantly turn to face the player, instead of gradually rotating.


Here's my attempt:
http://cid-b1e7ee094271bbda.skydrive.live.com/self.aspx/Public/Arm.mfa

There are still several problems;

1.) The rotation of each arm segment is absolute - it should strictly be relative to the previous arm segment's angle.
2.) Arm segements can overlap, which looks bad
3.) It would be more efficient if the arm segments were a group / duplicates (would cut down on duplicate events).

It all depends on how much effort you want to put in Vs the results you want.

BTW: I gave up using an extension, as it didn't allow me to use a float as rotation speed, when rotating towards an angle.

The other thing I thought might be cool, is if the last arm segment were telescopic - it wouldn't be that much more effort to add, and it could look pretty neat



 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
4th January, 2009 at 02:37:23 -

I think you should look into inverse-kinematics, or using one of the physics extensions to reproduce this. There was a really really good example of inverse kinematics for MMF 1.5, but from memory it was reported that it was no longer working in MMF2. You could try using a physics object with joints and restrictions to 'push' the parts around.

* I just found the download for the inverse kinematics engine. I had posted it before and noticed that infact doesn't work at all in MMF2:
http://www.create-games.com/forum_post.asp?id=225625

If you really really really want it, you should try submitting the file to a member of clickteam because it worked so well in MMF 1.5

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Ecstazy



Registered
  04/01/2002
Points
  179

VIP Member
5th January, 2009 at 22:45:27 -

Thanks Andy, I'll see what can be done with that.

Sketchy your example crashes when I try to run it but I see what you did there, thanks a lot!

 
Amongst Strangers
http://www.create-games.com/project.asp?id=1445
   

Post Reply



 



Advertisement

Worth A Click