Make an actor swing (not accelerate towards)? ADVANCED HELP NEEDED
How would i go about getting an actor to throw a rope and swing at a fixed radius around an object? Not like Swing Knight where he accelerates towards the object i would like the rope to maintain the same length while keeping the actor on the end. I know there is probably some trig/algebra involved, but i cant seem to get it right (and I got a 4 on my AP calc test, so i know my math). Or could i make this happen with the magnitude function?
Say:
if ropethrown=true
change attribute "distance" to magnitude(abs(blockX-actorX),abs(blockY-actorY))
then inside that put this:
if distance ≠ 80
move actor to distance 80 away from object???? (dont know how i would do that)
I would also like for the movement to a certain distance away from the block to be smooth.
Can anyone help at all? I've looked at all of these pendulum and arc/swing templates and i just cant get this work. ANY help would be appreciated.
Say:
if ropethrown=true
change attribute "distance" to magnitude(abs(blockX-actorX),abs(blockY-actorY))
then inside that put this:
if distance ≠ 80
move actor to distance 80 away from object???? (dont know how i would do that)
I would also like for the movement to a certain distance away from the block to be smooth.
Can anyone help at all? I've looked at all of these pendulum and arc/swing templates and i just cant get this work. ANY help would be appreciated.
Comments
swing knight
Swing Knight is much better ;-P
I believe you find it when you search for Swing.
And, i currently do have it exactly like swing knight, i just think it would be better for my game if i can keep the character rotating around the thing the rope is attached to, rather than through it. Im looking up 2d physics motion for a pendulum now, thanks for the suggestion
I think I have a sample....
game.X and game.Y are constrained to the object you are rotating.
the 70 bigger goes faster, smaller goes slower is the speed, the % is mod so you wrap at 360 for a full circle, * 25 is the offset distance in pixels from the center.
y = game.Y +sin(( self.Time *70)%360)*25
x = game.X +cos(( self.Time *70)%360)*25
It turns out using just sin or cos and leaving the other alone is a really good way to make a back and forth motion ;-P
I'll make a demo tonight when I come home from dancing and drinks.
It needs some work on the starting position, but other than that, I think it is fine.