Jump to content

  • Log In with Google      Sign In   
  • Create Account


Better slope collision on platformer game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Zotoaster   Members   -  Reputation: 148

Like
0Likes
Like

Posted 05 January 2014 - 09:43 AM

Okay so I have collision with slopes working fairly well on my platformer but I'm thinking it could be better.

 

Basically, I'm using the Tiled Map Editor, and I draw polylines on the floors where you're supposed to collide. In the game, I basically create a ray between the player's current position, and the position he's going to be in next, and check if it intersects one of these lines. If it does, the "onGround" bool is set to true (which disables gravity), and then I get the gradient of the line segment, find out how far along the X axis I am of it, multiply that by the gradient and set that as the Y coordinate. Simple maths, but it works and it's solid.

 

However, when I'm running downhill, I'm moving along the X axis, leaving the ground for a bit, falling until I hit the ground, etc. So very little time is actually spent on the ground, which means you can't jump ('onGround' has to be true to jump).

 

So, I was thinking of following these paths directly, but it's a little bit complicated and I'm confused about how to do it. Note, there are many polylines per level, and most have more than one line segment to them. Does anyone have any experience with this? I could use some help.

 

Thanks



Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS