Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_on_floor() reports inconsistently with move_and_collide() used to stair-step #72822

Open
8bitprodigy opened this issue Feb 7, 2023 · 8 comments

Comments

@8bitprodigy
Copy link

Godot version

4.0

System information

Manjaro Linux

Issue description

When implementing stair-stepping similar to how Quake handles it, is_on_floor() seems to report inconsistently, seeming to flip-flop between the two every _physics_process() tick.

Steps to reproduce

Surround your move_and_slide() with a move_and_collide(step_height_vector) before and a move_and_collide(-step_height_vector).

Minimal reproduction project

https://share.internxt.com/d/sh/file/c585190d7d9735382cbe/ec92284f02eb5c30d40d0962606054f4f124638a96392993ddc65469885b5896

@8bitprodigy
Copy link
Author

I would like to add that this is when using a cylinder collision shape.

@Calinou
Copy link
Member

Calinou commented Mar 25, 2023

I would like to add that this is when using a cylinder collision shape.

Cylinder collision shapes have many issues – I currently recommend using capsules or better, boxes.

@8bitprodigy
Copy link
Author

Cylinder collision shapes have many issues – I currently recommend using capsules or better, boxes.

Well I've tried capsule, and it's even more broken for me, but I'll try box. That said, cylinder would be ideal, as you won't get pushed away from walls when rotating(unless you keep it axis-aligned), and you can still walk along edges without falling off.

@8bitprodigy
Copy link
Author

8bitprodigy commented Mar 27, 2023

So it does fix the teleporting, but is_on_floor() is still broken, so I still experience some motion stuttering near edges of shapes, even with my workaround _is_on_floor() function.

@yosoyfreeman
Copy link

This one happens because CharacterBody relies on the slide collision for floor check. Every frame you are teleporting the character to the air, it moves towards the wall that is the next stair, which is not a floor, then move downs, which does not update is_on_floor(). What is needed here is a way to force a floor detection check to manually update it after custom behaviour.

@8bitprodigy
Copy link
Author

This one happens because CharacterBody relies on the slide collision for floor check. Every frame you are teleporting the character to the air, it moves towards the wall that is the next stair, which is not a floor, then move downs, which does not update is_on_floor(). What is needed here is a way to force a floor detection check to manually update it after custom behaviour.

Thanks for the info! And yeah, not sure how to go about that. That said, there is now a shape-collider, which can be used to implement the same sort of behavior without moving the characterbody around, though I don't know if the effects are 1:1, though, from what I've heard so far, they appear to be.

That said, that still leaves the jitter, but that also appears to crop up with this stair-stepping code.

@yosoyfreeman
Copy link

If you are referring to separation rays they are not a good alternative for this, they lack the surface area required to work and the way they separate the body will push it trough geometry on the ceiling if you get over a stair which does not have enough space over you.

@8bitprodigy
Copy link
Author

No, I'm talking about shapecast. It's a single cast, but rather than a ray, it's a 3d shape in a straight line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants