Hi people, first of all thanks for reading this, and sorry if my english isn’t that good.
I’m here for asking help cos during the develop of my game i met something that i think it should be defined as bug, but before saying that, i wish to know if the situation i want to happen can be accomplished with other methods.
Basically i have my player head and sprites who face toward my cursor succesfully.
with something like change p1.angle to mouse X(), mouseY () , but then i tried to limit the angle.
And i did it succesfully with clamp function Clamp (p1.angle,angle min, angle max)
e.g clamp (p1.angle,-5,10). and the face move smoothly between angles -5 to 10 °.
and it does work if i’m facing to cursor x>0, but when i flip to the other side it doesn’t work, not matter what or it does work partially
if i clamp to the other side the head stop right before the 0 At 179,99 and wont go up at the top left (top left of the cartesian coordinates).
So i’m asking why the clamp function works to the right side (where there is a zero too) and it doesn’t to the left/flipped side? Please if you can replicate this issue cos i’m stucked at making my pretty plattyform. Just wanna try to limit an angle to the left side with head following the transition smoothly.
I’m on the latest beta of Gdevelop 5.
I would first add a text box to your screen that tells you the current p1.angleToMouse
This might help you better understand what’s happening.
If you are getting negative values, then maybe you’ll need to use abs()
Next I would check to see if the Clamp function always expects the lowest value as the first argument.
You can always fallback to using a couple of conditionals for each facing direction instead of clamp.
I’ve indeed made a text box with p1.angle and i tried your suggestion with more conditions even related to other objects without success. basically i see the angle goes from 175 to 0 and that is ok but than it doesnt go up to the negative values cos …ofc…they are negative…
This evening i’ll try with tha abs function …thx for the input…
but still i don’t get why the clamp function works to right where there are negative values too!!..and don’t to the other side…
If someone could make a simple working example/project it would be great
Bump,…tried with no success…still need help, i made a ss…please ignore the flips actions
Try use in bottom code:
set to clamp(p1head.Angle(),-10,5)*(-1)
This way you inverse it all.
Nope…tried,…also i don’t think you can invert angles like that…it will be a dream… It still face at 10,-5 degrees and to the right ofc since you just inverted the sign of angles.btw thx you tried.
Still need help…siggh
Well, it worked for me, but partially. The transition is not smoothly It jumps from 5 to -10 and vice-versa.
Yes idd, but if you try at the right side (i mean if you try my working* code) you should notice a lot of difference in moving…and that isn’t normal since the conditions are the same
Actually it looks solved. Thank you both for inputs.
Still it is strange since while it works for a side it doesn’t works for the other. Anyway here’s the pic for a temporary solution
LOL, I got so pulled into this one that I implemented a working project:
Looks like you already figured it out while I was implementing though.
But just in case someone else wants to check it out It’s linked above.
Thank you for uploading the example, but i don’t see your character to flip when mouse x<0 is that normal? it stops at 0° angle…edit: ok i guess you need to press direction…it works btw.
I’ve now fully solved my problem!here the v2.0 fix but still i don’t think gdevelop handle well this conditions . it is clearly visible when angle is at 0=180°