The Daily Click ::. Forums ::. Klik Coding Help ::. Simple Verlet / Puppet Strings Method?
 

Post Reply  Post Oekaki 
 

Posted By Message

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
31st March, 2010 at 03:56:34 -

What I'd like to do is to have my character's weapon swing and angle as he moves and when he jumps ... and for it to drag behind him (think of a caveman dragging a club behind him)


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

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

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
6th April, 2010 at 01:21:07 -

Thanks for all those wonderful answers ...

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

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

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

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
6th April, 2010 at 04:35:14 -

I'm having a bit of a hard time visualizing what you're describing. Do you have an example video of it in another game? Or could you describe it with pictures perhaps?

 
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

OMC

What a goofball

Registered
  21/05/2007
Points
  3539

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
6th April, 2010 at 12:14:50 -

Do you mean you want a separate arm that swings with physics?

 

  		
  		

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49614

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
6th April, 2010 at 16:05:23 -

You would need to get the angle between the characters current position and his last one, then use linear interpolation to swing the weapon smoothly from its current angle to the angle calculated.

So for the angle, assuming the player is named "Player" and "LastPlayerX" and "LastPlayerY" are alterable values:

ATan2( LastPlayerY - Y("Player"), X("Player") - LastPlayerX )

Should get you the angle pointing behind the players movement direction.

Then for linear interpolation, assuming the calculated angle from the equation above is "MoveAngle"

Set angle of object "weapon" to
angle("weapon")+((angle("weapon")-MoveAngle)*0.2)

This should work, but I haven't tried it yet so good luck!

 
n/a

aphant



Registered
  18/05/2008
Points
  1242
6th April, 2010 at 18:36:42 -

Have you considered simply animating it?

 

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49614

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
6th April, 2010 at 19:28:41 -

Wait! I just realized that the interpolation part won't work because the formula doesn't take into account the fact that an angle wraps at 360 degrees. If anyone knows a fix for this, post it because I'm curious too!

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
7th April, 2010 at 03:49:39 -

Thanks for the responses.
The weapon should feel like it has weight to it and its angle should change when it collides with the ground.
I'm not one who understands all the extra computational explanations easily, but ..
.. there's no need for any thought on relative positions, it just has to ...
.. hmm .. yea .. it just has to add or subtract to the angle while the character's walking animation is playing and the weapon is overlapping a background ... that's it really, guess I sorta worked out part of the solution while trying to explain it ..

Ok, so I can do that by changing the direction of the weapon and by setting the weapon to the action spot on the characters hand, so I guess the new question would be smooth 360 degree rotation of the weapon instead of using the directions ... anyone have a nice simple method that works with TGF1?
(I still prefer to code everything in TGF1) (usually only use MMF2 to help others/compile for contests/etc)

@OMC: that's a good description of it if the word arm is replaced with the word weapon, basically everything would be normally animated except the weapon which would instead use rag-doll physics. That's what I'd prefer, fully operational physics for the weapon.

@everyone: I prefer answers that work with TGF1, BUT a MMF2 answer will still help me, please don't misunderstand and think that if you only use MMF2 you can't answer for some odd reason, thanks guys!, looking forward to your responses.


Edited by MBK

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

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

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49614

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
7th April, 2010 at 14:01:18 -

Just convert the 360 degree angle into 32 directions and use that to set the weapons direction. It won't be "smooth" as you said though. There's a reason everyones switching to mmf2 you know.

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
7th April, 2010 at 21:53:36 -


Originally Posted by UrbanMonk
Just convert the 360 degree angle into 32 directions and use that to set the weapons direction. It won't be "smooth" as you said though. There's a reason everyones switching to mmf2 you know.



Yea ... this is the main problem I have now though ... there's many examples for 32 directions in TGF1, but it seems like there's no way to make it true 360 rotations, creating the different directions on its own without a directional reference. Is there no way to simply rotate the current sprite on the direction rather than switching to another sprite contained in a different direction?

CONSTRUCT seems to be able to do 360 almost automatically, it's quite nice for that, but lacks in alot of other areas that I often use.
Does MMF2 Developer have the ability to use 360 degrees in such a manner? .. If so, where are the settings? .. How do I make it happen?
I'll start using MMF2 and forget about TGF1 for any projects using 360 rotations if the functionality is there and easy to use.



 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

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

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

OMC

What a goofball

Registered
  21/05/2007
Points
  3539

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
7th April, 2010 at 22:13:05 -

Yup, it's under "scale/angle".

 

  		
  		

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
7th April, 2010 at 23:09:21 -

Is that the one that distorts the picture when it rotates, cause if so that's not what I'm looking for. ?

I'm completely MMF2 Illiterate, I've been looking around and I can't even figure out how to add more directions to an active ... it's stuck on 4. ... heh.

Edit: I found how to add directions up to 32 now, seems odd to me that it's a scrollbar.

You know ... why don't they just make it go up to 360 directions? or 720? or 1480? ... seems like it could use the same code to calculate them for ya. I know 360 directions isn't exactly the same as 360 but it should be more than enough to look smooth.

Note: I still can't find a way to rotate the sprite itself without picture distortion in MMF2. Check out Construct and you'll see what I'm talking about.


Edited by MBK

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

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

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

OMC

What a goofball

Registered
  21/05/2007
Points
  3539

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
7th April, 2010 at 23:23:38 -

Setting the scale can distort, but setting the angle shouldn't. Having 360 animation directions would be unnecessary and confusing. Having 360 pretend directions... is what setting the angle is.

Edited by OMC

 

  		
  		

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
7th April, 2010 at 23:46:30 -

oh ok .. thanks OMC

There's a way to change the angle during runtime right?
I'm gonna look for that now.

Edit: Ok, that's neat ... thanks again OMC ... I'm very tempted to move the project to MMF2 now .. there wouldn't happen to be an angle setting extension for TGF1 would there?

Edit2: Crap! .. I'm stuck again! ... I can't find where it shows the size of the sprite or how to change it!

Edit3: Nevermind ... oddly it's in with the art tools ... you'd think with all that blank space they could just leave it displayed on the left.

Edited by MBK

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

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

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49614

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
8th April, 2010 at 00:20:13 -

I can't believe you've had mmf2 all this time and haven't started using it.

Good sir please spare yourself the heartache of using out of date tools

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
8th April, 2010 at 02:01:39 -

I dunno dude ... I've been experimenting with it and ... this MMF2 interface is giving me a headache ... I can't even figure out how to make a spaceship move in 360 with realistic thrust.
All I can find is some "spaceship" scheme in an extension (bleh) that works like Oddro (not at all what I was trying to do).

I can probably get past the rotate the sprite problem in TGF1 by using a seperate active and moving its position around the character in a circle then tell the character to look in its direction really ... I just wish there were a more elegant solution.

Anyway, so far in MMF2 I have a spaceship that rotates the angle left and right by pressing a or d.
It also can shoot, but the odd thing is that when I set the direction it is to be shot towards as the angle of the spaceship, it's quite off. The action points and hotspots are all aligned, I just mean that it rotates the shooting angle faster than the spaceship angle. This is clearly because there are only 32 directions and it limits the bullet angle shot in because of that.
(clearly just having 360 directions to work with instead of 32 would make things much much much easier)

Now I'd like to figure out how to move it forwad with thrust based upon the angle but I haven't gotten a clue.
If this gets solved, then I could just do the same thing for shooting.

Edit: I bet if there were 96 directions (or maybe even 64), then most everyone wouldn't even need to bother with 360 custom movements.
just those extra directions would probably make it smooth enough.


Edited by MBK

 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

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

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49614

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
8th April, 2010 at 16:59:41 -

Your going to have to make a custom engine.

a 360 degree movement engine.

You can either use the Advanced Direction Object which is easier to use.

Or just trig, then you don't need an extension.

Create three new Alterable Values for the ship and name them:

ShipX
ShipY
Speed

Then do this:

Start of frame-
Set ShipX("ship") to X("ship")
Set ShipY("ship") to Y("ship")

On ThrustButton- (This is whatever you want to make it accelerate, you can change 8 to whatever you want the max speed to be, and 1 to whatever you want the rate of acceleration to be)
Set Speed("ship") to min(Speed("ship")+1,8)

On NOT ThrustButton- (Whenever the user let's off the ThrustButton it decelerates the ship)
Set Speed("ship") to max(Speed("ship")-1,0)

Always-
Set ShipX("ship") to ShipX("ship")+(cos(angle("ship"))*Speed("ship"))
Set ShipY("ship") to ShipY("ship")+(sin(angle("ship"))*Speed("ship"))
Set X position of object "ship" to ShipX("ship")
Set Y position of object "ship" to ShipY("ship")

There, a simple 360 degree movement engine with acceleration. You might need to tweek the numbers for it to work well though.

WHOOPs forgot rotations!

On Left-
Set Angle("ship") to Angle("ship")+2

On Right-
Set Angle("ship") to Angle("ship")-2

Blah!

Edited by UrbanMonk

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
15th April, 2010 at 02:43:45 -

Thank you much guys, especially UrbanMonk
I'm still a bit stumped at the math, but it's slowly sinking in to my thick head.

There's one thing regarding the swinging object which makes it harder than the spaceship in a way, and that's gravity acting upon it as the weapon spins round the hotspot/action point ... I'm still clueless on that so I guess just changing the direction or adding/subtracting to the angle will have to do for now.

Thank You All!
I may need more help with it later, so try not to get too mad at me if/when I ask again.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

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

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49614

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
15th April, 2010 at 04:25:08 -

I won't be mad.

 
n/a

Rob Westbrook



Registered
  25/05/2007
Points
  193

360 OwnerVIP Member
15th April, 2010 at 18:32:45 -

Just pointing out that UrbanMonk's example has more of a car feel to it rather than a spaceship. I'm not having a go at his example before anyone thinks that, I'm just saying x) Sketchy's useful formula article has the basics for creating an Asteroids style movement which I've used many times in the past http://www.create-games.com/article.asp?id=1898

 
There are 10 types of people in the world: Those who understand binary and those who don't.

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
15th April, 2010 at 21:45:35 -

Thank You for pointing that out Rob, I need all the help I can get.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

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

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49614

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
15th April, 2010 at 22:23:15 -

Yeah, it's a very simple 360 degree movement example, and wouldn't be for anything that uses angular momentum.(If that's even a term. )

 
n/a
   

Post Reply



 



Advertisement

Worth A Click