godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add a `SeparationCylinderShape3D` and `radius` to `SeparationRayShape3D`/`2D` #9730

Open ettiSurreal opened 6 months ago

ettiSurreal commented 6 months ago

Semi-related: https://github.com/godotengine/godot-proposals/issues/2751

Describe the project you are working on

Experimenting with a 3D Platformer.

Describe the problem or limitation you are having in your project

This is not exactly a problem I'm currently facing, but still wanted to bring this up. SeparationRayShape2D is a great feature, it lets you for example:

SeparationRayShape3D uses the same concept, but in 3D it kind of falls apart due to omnidirectionality. To do the things I've mentioned above, you'd need to have many individual collision shapes (potentially hundreds), which I imagine would negatively impact performance, and give you a "cogwheel effect" where you can get inbetween collision shapes on corners or small collisions.

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

To me, an obvious solution is to: A) add a new shape that would function exactly like SeparationRay, but in a circle with optional height (so you don't have to duplicate it). Would solve the "jumping into ceilings" example. B) Add cylindrical radius to SeparationRayShape3D (and potentially 2D, for consistency), It would be an easy solution for stepping. This will not work for shapes that aren't capsules, spheres or cylinders though, so if this is big enough concern, a rectangular or polygonal mode would be required.

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

A new SeparationCylinderShape3D collision shape. It would have have radius and height settings like CylinderShape3D, but function similarly to a SeparationRayShape3D, where it would push itself away (or colliding objects away from it) if they entered the collision from either top or bottom cap. Basically just imagine a shape that's an infinite amount of SeparationRayShape3Ds spun in a circle, duplicated an infinite amount of times across a straight line. image

A radius parameter in SeparationRayShape3D (and potentially 2D), it would add a cylindrical volume to the ray, so it would basically work as an opposite to the shape proposed above. image It could also potentially support rectangular or polygon shapes, if the issue stated before is high enough concern.

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

Is it even possible to make custom Shape2D/3D derived collision shapes? I haven't seen anyone do that.

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

A more useful version of an existing feature.

AThousandShips commented 6 months ago

I'd say this should be two different proposals, as one is about adding a new feature and the other about changing an existing one, arguably in a way that affects the exiting use cases of it, that would need to be discussed more, so it'd be more useful to separate the two