Change player angle according to the slope

0 favourites
  • 9 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hi

    I have searched for this topic, but didn't find much. I'll try to explain what I m looking for.

    For e.g. If I have a running horse and I want it to change its angle according to the slope(solid) on which it is placed. Like if its climbing a mountain, it's angle should change according to the mountain and it should tilt, In my case the horse just stays straight throughout.Can anyone please explain how this can be done??

    Thanks

  • Hello karan316,

    The first thing you need is for a given horse to know on what slope it is standing. All depends on how you display/create your slopes though, but we can assume the horse is overlapping with the floor. If so, an event "Horse is overlapping with Slope" could let you adjust the angle every tick.

    Now that you know what slope the horse is currently on, you need to add some sort of variable on every slope that stores the angle at witch the horse should be when it is there. Let's say you have this variable "horseAngle" on the Slope object.

    Now your event is :

    Horse is overlapping with Slope => Horse set Angle to Slope.horseAngle

    Of course, you will need to prepare this variable on each and every slopes.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for your reply.

    Must say, pretty happy to buy Construct 2. Someone or the other is always there to help when m stuck. The tutorial section is also awesome.

  • M still not able to get it done, can any1 please link me to a tutorial or show some example??

  • If you describe how you have your slopes set up someone can help, but the solution will depend on that. E.g. off the top of my head, if you are careful to set up all your slopes the same way by taking a horizontal rectangle and rotating it clockwise, then you would simply need to check if the horse overlaps that rectangle and rotated it by the same amount. But if you're doing something else that solution won't work.

  • Try this, it's fairly general so it should work:

    Assuming you're using the platform behavior, put every single object that could be a platform in a family called Platforms

    Every Tick --> Set Player Angle to 0
          Player is Overlapping Platforms at X=0, Y= 5
          Platforms Pick Nearest, Player.X, Player.Y   --> Set Player Angle to Platforms.Angle[/code:mjxwhive]
    
    You need to make sure that you don't rotate platforms more than 90 degrees or else bad things will happen
  • I made an example for this on the forum not too long ago.

    I will have to search the forum to find it.

    there's an old example in the arcade, which I adjusted to recognizing the slope angle as explained in the above posts.

  • Thank you all for your help Really appreciate your efforts..

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