[SOLVED] Climbing a tilting pole

0 favourites
  • 9 posts
From the Asset Store
You should help Choli to climb the mountain and reach its peak
  • Hi everybody,

    I'm trying to create a mechanic where the player can climb up and down a pole. The problem is that the pole can tilt left and right and the player needs to stick to it as it tilts.

    While the pole is vertical it's easy enough to say Player.X = Pole.X however once it begins to tilt the player's X value doesn't match that of the pole. In trying to wrap my head around it I'm not entirely sure that the X value of the pole stays the same even though I have set the origin point to the base of the pole.

    Capx - https://drive.google.com/open?id=1_R1tb ... WS5C1NJwcK

    W - moves player up, S move down, Mouse buttons make the pole tilt.

    Would anyone know how to keep the player in line with the pole as it moves?

    Any questions then let me know

    Thanks all

  • Here you go:

    Of course, you can do this in one formula, without the "v" variable.

    If you need a constant climbing speed no matter what the pole angle is, instead of "Set Y to self.Y+5" you can add an instance variable ClimbProgress (changing from 0 to 1) and then your event could look like this:

    Set X to lerp(spr_Pole.X, spr_Pole.ImagePointX("PoleTop"), ClimbProgress)

    Set Y to lerp(spr_Pole.Y, spr_Pole.ImagePointY("PoleTop"), ClimbProgress)

    Also, you should not change the angle of Physics (or Chipmunk) objects directly. Instead of "Pole->Rotate" you need to apply force or impulse to PoleTop image point.

  • That. Is. Brilliant! It's done the trick thanks dop2000! I used an impulse as well to move the pole which works much better.

    Regarding the ClimbProgress bit, what is it that changes the value from 0 to 1? Is it using the unlerp again to get the value between the top and bottom of the pole?

    Thanks for your help!

  • ClimbProgress=0 when the player starts climbing and ClimbProgress=1 at the top.

    You can add something like 0.01 or 0.005 to this variable when key "W" is down.

  • Ok cool, nice one Just have one more question if you don't mind...

    As the pole tilts, the player slides off it by itself before it hits the ground. Do you know a way to stop this from happening? Essentially so if the pole falls over with the player still on it, the player stays stuck to it? I thought it may be a case of using the lerp in a similar way but with Y values but doesn't seem to work.

    Thanks again!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • StomachBug

    If you did this with ClimbProgress (0..1), this shouldn't be happening..

    Could you share your project?

  • dop2000

    Ah I see. I believe I've put it in the wrong place then. Wasn't sure how the Set X works tbh, is that meant to be instead of the events related to the local variable?

    Here's an updated version, thanks for the help

    https://drive.google.com/open?id=1CnpZF ... WZFHffpl3s

  • You had a bit of a mess in events sheets. There should only be one event that changes (x,y)

    https://www.dropbox.com/s/3vjkfpnk0mtnl ... .capx?dl=0

  • Ah.

    Well that makes more sense than what I was doing. Think I was just over complicating it, what you've done is very effective with few events.

    In any case that's done the trick, thanks again

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)