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

Add edge compensation for KinemeticBody 2D/3D collision shapes #3258

Open
elvisish opened this issue Sep 5, 2021 · 6 comments
Open

Add edge compensation for KinemeticBody 2D/3D collision shapes #3258

elvisish opened this issue Sep 5, 2021 · 6 comments

Comments

@elvisish
Copy link

elvisish commented Sep 5, 2021

Describe the project you are working on

A first person shooter.

Describe the problem or limitation you are having in your project

When dropping off ledges using a capsule shape, the rounded edge is noticeable during lowering down. It didn't happen with games like Doom or Quake as they essentially used box colliders (Doom used a rectangle since it's a 2.5d engine).

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Edge compensation simulates a cylinder shape (if using a capsule) when over an edge, it does not simulate this shape during any other time so as to be able to traverse terrain and slopes more reliably.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

image
Normally, when a character is standing on an edge, it's collision shape will make contact with it. What edge compensation does is to lift up the capsule, simulating a cylinder shape.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, it would need to be part of KinemeticBody.

Is there a reason why this should be core and not an add-on in the asset library?

It would need to be part of the KinemeticBody core code.

@Calinou
Copy link
Member

Calinou commented Sep 5, 2021

Related to #2751.

Do other game engines support this? To me, it seems like you should use a cylinder shape instead. Relying on the capsule's edges for stepping on stairs isn't a good idea as it's slow and causes unnecessary "bumping". Instead, you need to use one or more raycasts to step on stairs or use invisible slopes (clip brushes) for stairs. Using a mix of both approaches is quite common in practice too - this is how it's done in most Source games.

For smooth movement on terrain and slopes, a cylinder shape should work just fine (like an AABB, in fact).

@Calinou Calinou changed the title Edge compensation for KinemeticBody 2D/3D collision shapes Add edge compensation for KinemeticBody 2D/3D collision shapes Sep 5, 2021
@elvisish
Copy link
Author

elvisish commented Sep 5, 2021

Related to #2751.

Do other game engines support this?

Yes, a couple of Unity asset controllers do in fact support this.

To me, it seems like you should use a cylinder shape instead. Relying on the capsule's edges for stepping on stairs isn't a good idea as it's slow and causes unnecessary "bumping".

For smooth movement on terrain and slopes, a cylinder shape should work just fine (like an AABB, in fact).

I wasn't sure if there'd be a down-side to using cylinders instead of capsules for terrain and such, it's good to know it shouldn't cause a problem.

use invisible slopes (clip brushes) for stairs

Really don't think this should be necessary (merely optional) at all in a modern game engine, although that is an issue for another proposal entirely: #2751

Also, this would be very useful for KinemeticBody2D where you'd want a capsule for slopes so the character doesn't levitate weird, but also falls straight down off an edge.

@KeyboardDanni
Copy link

It didn't happen with games like Doom or Quake as they essentially used box colliders (Doom used a rectangle since it's a 2.5d engine).

The way Quake addressed this problem was by extruding the collision shapes in the map at compile time three times, for different object sizes, and then simply performing raycasts at runtime to check for collisions. Of course, this is quite limited and wouldn't be a good fit for an engine like Godot. If anything, I'm curious how Unreal handles this.

Yes, a couple of Unity asset controllers do in fact support this.

Do you have any good examples of Unity asset controllers? How do they approach the issue?

@elvisish
Copy link
Author

Yes, a couple of Unity asset controllers do in fact support this.

Do you have any good examples of Unity asset controllers? How do they approach the issue?

https://assetstore.unity.com/packages/tools/physics/character-controller-pro-159150

https://assetstore.unity.com/packages/tools/physics/kinematic-character-controller-99131

https://assetstore.unity.com/packages/tools/physics/character-movement-fundamentals-144966

There was one more but I can't remember what it was called as I haven't touched Unity in a couple of years 😄

@KeyboardDanni
Copy link

None of the controllers you linked here appear to have any edge compensation according to their WebGL demos. The third one does at least push the character off the ledge so they're not sinking/hovering in the air, but it also tends to throw the character away from the ledge.

@elvisish
Copy link
Author

None of the controllers you linked here appear to have any edge compensation according to their WebGL demos. The third one does at least push the character off the ledge so they're not sinking/hovering in the air, but it also tends to throw the character away from the ledge.

I'm certain Character Controller Pro does, but since Godot supports box colliders it is pretty unnecessary to use capsules if you want boolean ledges.

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