Slopes, Inclines etc in platformers

Hi Everyone,

I discovered Gamesalad about a week ago and love it. Really wish I'd found it sooner!

I'm making a platformer and am having some trouble with my character dealing with slopes properly. I've seen some very good free demos on here suggesting constraining the character's rotation to the floor's rotation so that gravity doesn't make them slide down and so their graphics are rotated accordingly. However, colliding with a rotated 'floor' actor from the side or below ( one they are not standing on) still caused my actor to rotate, and he also still slides a little when standing on an incline.

Ultimately, I've found a slightly different 'solution' but want to know if there is a way to calculate the Y coordinate of a point on a rotated floor's collision box? I've currently constrained a global attribute to 'self.Position.Y +( self.Size.Height /2)' for whatever floor my character is standing on, but this does not work for inclines as obviously just creates a straight horizontal line above the centre point.

I thought I had it figured with some long winded trig, but no luck.

Any advice is welcome!

Thanks

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    want to know if there is a way to calculate the Y coordinate of a point on a rotated floor's collision box?

    Are you wanting to know the highest point of the actor regardless of its rotation? Like this?

    And which specific point? The vertex? Or any arbitrary point?

    (The line represents the highest point, not the platform which would obviously be slanted as necessary to hold the actor.)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited January 2015
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Or more specifically, is this the point you want the position of?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    Or more specifically, is this the point you want the position of?

    The distance from the centre of the blue actor/square/you/the box to a corner is 141.4591% of half the width, you should be able to work it out from there.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You wish! Wait, no, I wish. I found a site that explained the math but it was slightly over my head so I knew if I just waited, @Socks would come along.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2015

    @tatiang said:
    You wish! Wait, no, I wish. I found a site that explained the math but it was slightly over my head so I knew if I just waited, Socks would come along.

    Lol ! :smile:

    You can describe the absolute Y position of a corner of a square by measuring the sine of its rotation +45° (this is the upper righthand corner I am looking at, so +45°) multiplied by 1.414591 * half the square's width + the square's absolute Y position, which should look something like this . . .

    sin(self.rotation +45) *(1. 414591 *(self.width /2))+self.Y

    . . . that should give you the position of the upper righthand corner (I'll check it out in GameSalad in a minute just to be sure I've made no mistakes) - and the other 3 corners are just the same deal but offset by 90°.

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2015

    . . . just checked in GameSalad works fine, that formula knows the Y position of the upper righthand corner of a square wherever it might be in the scene.

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2015

    Here you go, I made a line that tracks the Y position of the upper righthand corner of a square.

  • FreemanFoxFreemanFox Member Posts: 2

    Hi everyone, thanks for all the very quick responses. Some look like they could prove useful, though I'm not sure I explained the problem quite well enough. Here's a pic explaining.

Sign In or Register to comment.