# Un-Official Documentation On Right Triangle Collision

Hello There,

(also sorry for sloppy writing i’m on only like 4 hours of sleep)

This is a simple documentation on calculating a players collision on a 45 45 90 triangle - im writing this in regards of @Crosbyman64 and making it a topic so others can also use my thoughts.

One useful equation to note would be the slope function or as commonly known a^2 + b^2 = c^2
Example:

This is useful as we’re able to take the length of the slope to calculate the height corrections,
First we start with finding the x and y values of each object so we need the players and the slopes. (This is only used on other shaped triangles then a Right Triangle)

Pro Tip

Make the x and y values a variable so it can be changed by any object its simply needed two things a new personal variable called x and one called y and this line of code,

``````When(Game Is Playing)
Set Position ((self) x ) , ((self) y )
``````

Current Variables:
Player X
Player Y
(Self) X
(Self) Y

Second we must find the distance of the x Values we will simply do this by subtracting the slope x from the players x.

Player X
-Slope X

New Variables
(self) X Distance
(self) Slope Height

Third we will then find the need height based off of our distance,

``````Set((Self) Slope Height) , ((((Slope) X) + ((Slope) X Distance) + (((Player) Height) +  1)
``````

Lastly we then use @Spy_Guy_96 Platformer collision code to detect the certain sides if u would like a tutorial on that let me know and ill provide with Spy-Guys Exclusive Permission Only

Tags
13 Likes

Here’s an example I made with a fully working slope collision.

For a left facing slope, of course.

Formula for a slope: y = mx + c

m = slope gradient (steepness), c = y intersect.

Also, all of Spy Guy’s code are free to use with credit.

11 Likes

Why was @/GoatTagList tagged?

4 Likes

because i have permission from goat to use it lol dont worry it will never be spammed

5 Likes

Ok i thought Goat was back

3 Likes

Haha that’s funny

4 Likes

Hey GOATGAMES, how’s it been?

3 Likes

Haha how strange would that be?

Miss you bro!

2 Likes