Direction of the platformer character

Is there a way to tell if a platformer character is facing left or right?
Sometimes, when a platformer character grabs a ledge, it faces the opposite direction as if it grabs with its back. :smiley:
I guess this happens when you press backward arrow when the character is jumping forward (it is rare but possible).

I corrected this issue in my game, i don’t remember how now (and i don’t have source on this computer).

Top detect the direction, you can use sprite inversion horizontal conditions/actions. Personnaly i always track in variables sprites orientation, it’s usefull in a lot of events.

Really?
I wonder how do you do that.
I have to rely on key press event.

Basically i think that i just stop the event wich manage sprite orientation change when a border “is grabbed” (“border” being a group of objects, with all objects of platform kind). I should look at my source to confirm… But in the meanwhile try what i’ve written.

If I have a way to tell which object the character is grabbing.
Maybe checking the positions of them?

Create a group of objects “MyGroup” wich contains only platform object with “grabbed” feature, so whatever is the object, you just need to handle an event “for each ‘MyGroup’”. With this you’ll be able to triger specific action when the object from the group “is grabbed”.

But how do I know it is grabbed? I can’t find it in the condition editor. For example, if I have 2 platform objects that can be grabbed, how do I know which one is being grabbed by the player?

Just make a variable “Direction = 0” then just

0 = right
1 = left

if left key pressed – do var Direction = 1
if right key pressed – do var Direction = 0

if grab – change sprite “sprite_grabing”
if Direction = 0 – flip sprite “sprite_grab” horizontal = no
if Direction = 1 – flip sprite “sprite_grab” horizontal = yes

Variables can be used to do a lot of good and easy things. :smiley:

1 Like

That doesn’t work well because there is a chance you press the key in the same time the character grab the platform.
The “is grabbng platform” status is not available until next frame, so gd thinks the character is not grabbing platform thus flips the direction.

I ran into a similar issue. It was really tricky but I eventually got it to where I liked it. Basically what I did was tell the platformer to release grabbing the ledge whenever he was not facing the ledge. For example If I pressed “left” when he was facing “right” he would just drop instead of flipping horizontally.

Maybe there is a better or easier way to do it in which case I would be interested to hear how its done but this is how I got it to where I liked it.

Hello!

In general, please avoid bumping threads that are over a year old. This thread was started for GDevelop 4 and was nearly 6 years old at this point.

That said, I’m glad you found a solution, and thank you for posting your events!

Due to the age of the thread, I will be closing it.