get slope of floor in platformer Games

Get help using Construct 2

Post » Sun Jun 02, 2013 12:45 pm


Hello my dear friends
firstly sorry for my bad English
I am new in construct and lately i worked with UDK
as i learned in UDK you can get slope of floor that your player is standing on as a floor property in pawn class
but how can i force my player to slide on some angle?
I know that using of physics my be the first solution that every body think about it, but my game design is like a platformer character
and adding physics to my character make it behave like a physical character
my question is this:
is there any way to get the angle of the slope of the floor that my player is standing on?

thanks for your time and attention
B
3
Posts: 7
Reputation: 739

Post » Sun Jun 02, 2013 2:18 pm

if your floor is made of sprites giving a graphical representation of a slope then you can give the sprite a variable based on that angle...

so if your slope is 45 degrees set the variable to 45...
then you can set the players angle based on that variable when he is stood on it..

remembering that 0 degrees is to the right,imagine East on a compass so 45 degrees would be South East on a compass, you would have to do a calculation to get the correct angle...Pixel perfick2013-06-02 14:25:19
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Sun Jun 02, 2013 2:39 pm

That's kind of a tricky one. You could easily find the floor object that's nearest to the player, and get its angle that way, but that works with the floor object's origin which might not always actually be nearest to the player (there could be another floor object's origin that's closer).

A way around this would be to keep your objects relatively small, which you can see in this example based on the platformer template.

Although that's not the most elegant or efficient solution, it might work for you depending on your design approach. I'd welcome any other ideas on the topic as it's something I might find myself facing one day.
B
57
S
15
G
11
Posts: 912
Reputation: 12,596

Post » Sun Jun 02, 2013 2:55 pm

I'll bet that you could modify the platformer plugin to return the floor slope, as it seems to use that value to determine whether it's on a slope or a wall.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,664

Post » Sun Jun 02, 2013 4:06 pm

If you're using collision tiles just check which one the player is overlapping at 0,1 and go from there. If not, try creating two detector objects to the left and right of your player that conform to the floor, get the angle between them, then set your player to it.
Image
B
238
S
28
G
13
Posts: 1,787
Reputation: 18,485

Post » Sun Jun 02, 2013 7:22 pm

Ah, @Tokinsom, you're spot-on. I always forget about overlapping at offset. Thanks for that.

Redcapgame, I've updated my example based on Tokinsom's suggestion.
B
57
S
15
G
11
Posts: 912
Reputation: 12,596

Post » Sun Jun 02, 2013 8:54 pm

firstly lets accept my special thanks about your kindly responses.
dear Pixel perfick in my opinion this solution really is hard for our level editors to manage such a idea
dear sqiddster i am going to test that but unfortunately i can not find some way to detect floor angle
dear Tokinsom i will check your solution
and dear GeometriX really thanks for your response i will check your file and tell you the resultRedcapgame2013-06-02 20:55:08
B
3
Posts: 7
Reputation: 739


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests