I need help with a bug, where when the player releases the crouch button while under an object, they start jittering underneath. I have been trying to fix it myself for about 2 days, I checked the forums, watched youtube videos, and even did debugging but I can’t get it to work no matter what I do. I would rather not use a new object, and would rather use collisions, points, and logic to keep the player crouching while under the object, and to stop after leaving.
Sadly, I can’t add multiple images, and I can’t show all of my code either.
Condition
Player animation is crouch
NOT
Point inside wall Player.PointX(“LP”) Player.PointY(“LP”)
NOT
Point inside wall Player.PointX(“RP”) Player.PointY(“RP”)
And in action you change animation or state to NOT crouching or standing or whatever
Green squares are points btw
Hi - you can check whether a custom point (at normal head height) is inside the platform object - you could put all the platforms in a group and check the group.
use this as a condition to turn crouch off along with the timer or however you’re doing
You can’t switch from a lower collision mask to a higher one inside a tunnel, for example. The moment the player hits their head on the ceiling, the collision mask gets pushed to the sides. You simply can’t do it
so keep your character crouched.
fix your logic at down keypress release to still use the crouched collision mask
also what zero’s said should fix the problem
debug your collisions mask
at the beginning of the scene—action–debug collision.
This only works when the S key is pressed. I think the rest is missing… and if you release the button and it goes back to idle, then the issue is there. I think you’re missing some additional logic.
Inverting is different to NOT - as zero says - you can also do it like this without a NOT
i used a boolean for crouch instead of having it part of the state
Under each state in which the player can crouch you’ll need to add the “s” key pressed condition and an action to change state to crouch. So that’ll be the idle state as a minimum.
Can they also walk or run and then crouch while moving? Then I’d suggest you have a “Run Crouch” and “Walk Crouch” states, so when the player stands up from those they can keep moving.
Yes, this will be a bit more work, but it’ll make the game function better.
Your right, I am gonna take a break and then rewrite most of the code so that I have a proper state machine, while using the tips you all gave me. Thanks for your time!
Thank you so much, I ended up rewriting the way my game does states and simplifying it which in turn made it easier to follow your example, and it works!