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
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
Would this help?
http://www.deepblueapps.com/gs-robot-demo/
Or more specifically, is this the point you want the position of?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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.
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
I think this might be a hint!
http://mathcentral.uregina.ca/QQ/database/QQ.09.06/h/graham1.html
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Lol !
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°.
. . . 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.
Here you go, I made a line that tracks the Y position of the upper righthand corner of a square.
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.