Trying to make a Swinging Player

TosanuTosanu Member, PRO Posts: 388

I am trying desperately to put together a behavior that when a player is close neough to an anchor point and holds down the trigger button, it creates a connection to that point and swings from it like a steady, non gravity affected pendulum. I used a good example for automatic pendulum someone provided me, but it still isnt quite working.

Here is what i have.

When Closeness(magnitude distance between player and hub) < distance and not touching ground
(
if hit button, swinging becomes true
)

In next attribute

If Game.Swinging = True
(
create new attributes Swinger X and Y and SwingPoint X and Y (player and hub)

self.swingangle = vectortoangle(swingerx-swingpointx, swingery-swingpointy)+ 80(this is supposed to be the max allowable angle)

swinglength = closeness
Gravity is switched off and velocity is set to zero

timer(every .025 seconds){

change swingingspeed = 10(-8/(swinglengthsin(swingangle)))

change game.swingspeed = game.swingspeed+selfswingingspeed

change swing angle to swingangle+ game.swingspeed

game.swingerx= (swingcenterX+ swinglength * sin(swingangle))

game.swingery = (swingcentery - swinglength*cos(swingangle))

change positions x and y to swinger x and y}

)

Unless otherwise noted, all changes are Change and not Constrain, and all attributes are either booleans or Reals.

And yet, as it stands, when i hit the button, the player freezes in place against the hub. If i hit the button repeatedy they teleport around the hub to a series of specific locations like a clock. What am i missing? I did the best i could to copy and adjust the code the person provided me with for the automatic example and turn it into an activatible trick, but it doesnt seem to be holding up right

Comments

  • TosanuTosanu Member, PRO Posts: 388

    ..... Ever find a single missed parenthesis that was destroying your entire calculation? What am i talking about, we all make games here, of course you have.

    I actually would like to change the question now, i got it working, but its rather jumpy, the character clearly stutters from spot to spot, should i just lower the timer interval or is there a better way to make that smooth?

Sign In or Register to comment.