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.
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.
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.