Gradually change player's angle on a slope/ramp?

0 favourites
  • 11 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hello All!

    I am trying to make the player's angle change gradually when he is walking on a ramp/slope (using the platform behavior).

    I searched and found this nice example by JohnnySix (Platform movement with Ramps), but this changes the angle instantly. I want to use the lerp expression to make the transition between the angles more gradual. But I am encountering the following problem:

    When the angle has a negative value in relation with the player's "0" angle reference, the rotation is going berserk! I admit, it does produce an interesting effect, like a tumbling, but it's not the result that I am after. With positive angles, the outcome is different.

    You can observe the problem here.

    And here is the capx file.

    Use the arrow keys to move...

    Can someone help me with this problem??? Or is there any other way to achieve the same result, I mean for the player to follow the curvature of the ground and change it's angle respectively??

    Thank you in advance!!!

    Elias

  • I may be able to help with this as I was facing something similar recently, something to do with weirdness about handling -angle values, but I have my own noob question first.

    It says the version of that capx was saved in release 141 or newer, so I can't open it. Where can I download that release version? I only see 139 on the site. Let me know so I can try and help :)

  • Wertle

    r141 is the latest beta version available here

  • Wertle,

    Hello, thanks for your reply!

    I jumped the gun and installed the latest beta because I wanted to test the ability to change global variables in the debugger and see the results in real time... <img src="smileys/smiley1.gif" border="0" align="middle" />

    As plinkie kindly points out, there is an r141 beta release.

    I am anxious to see what solution you came about to this problem!

    Thanks!

    Elias

  • So my theory about negative angles wasn't right, but I was able to get what you want using "Rotate Towards Angle" instead of "set angle"

    storage.wertle.com/construct2/SlopeAngleFixed.capx

    You can change the angle number to get a faster or slower transition

  • Dear Wertle,

    Thank you so much!!! <img src="smileys/smiley31.gif" border="0" align="middle" />

    Elias

  • Try Construct 3

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

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

    Apologies for reviving old thread.

    Why can i not call on object.Angle ?

    Why do i have to use an instance variable instead?

    The reason i ask is, it would save a lot of time during level design to just look at the solid's angle as opposed to adding slope helpers all over the terrain and manually adjusting the instance variable to match to angle degrees of the slope.

  • Ldk

    I am afraid I don't know how you could do that.

    Perhaps someone more experienced than me (honestly, I just barely understand the program and it's true potential) can add to your question some useful input.

    Why don't you make a new topic?

    Or ask Ashley? <img src="smileys/smiley2.gif" border="0" align="middle">

    -EDIT-

    I figured out a way, not very precise, not very elegant and it will produce some jerky results but, for all it's worth, here it is:

    Get Angle From Ground

  • When using lerp for angles you have to use anglelerp! This got me stumped a few months ago too.

  • Thank you andreyin , that's useful to know!

  • eli0s

    No problem! Also, when your sprite is mirrowed, you should use a negative angle in anglelerp, like this:

    <img src="http://i.imgur.com/fT6wHwQ.png" border="0" />

    Cheers!

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