-
-
Notifications
You must be signed in to change notification settings - Fork 97
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 a ConeShape primitive 3D collision shape #610
Comments
I second this, this a very useful shape, and it is already there in Bullet, I see this as an absolute win |
I just tried converting over some code to Godot that used Bullet directly, and I was very surprised to be unable to find a way to make a cone collision shape. |
I started to work on an Area3D field of view for ai and was looking for cone/pyramid CollisionShape but found none in the dropdown menu. This should definitely be a basic shape 😊. |
Note that Bullet will no longer be included in core in Godot 4.0. Therefore, a cone collision shape needs to be implemented in GodotPhysics before this can be considered. (This is absolutely required, as we can't implement a feature in 3.x only to remove it later in 4.0.) |
This comment was marked as off-topic.
This comment was marked as off-topic.
@gebba Please don't bump issues without contributing significant new information. Use the 👍 reaction button on the first post instead. |
It's also useful to discuss some ways in which this could be useful. -Cones can simulate NPC point of view collision. This is far more predictable and simpler than working with raycasts, and can be visualized to the player for instance in stylized top down stealth games, or where the NPC can only see by torch light. -Work well both for collision and aesthetics of spike traps -Achieve simple spotlight effects when given a transparent glowing shader -Cones can even achieve some simple architectural looks: -Can be the base if inverted or else the roof of a medieval turret |
Instead of using collision shapes, you probably want to use an analytic approach to detecting view sight (using the dot product). This way, you can determine how quickly an enemy should notice the player based on distance from the player, but also based on the angle relative to the player. A player that is 90 degrees on the side should generally take longer to be noticed that a player that is dead center in the enemy's eyes. By contrast, collision shapes are an "all or nothing" thing and don't give you any context other than "the player is in sight".
You can use trimesh collision for static level geometry, so it's not strictly required here. |
This would definitely be useful for creating vision cones for enemies. |
A better implementation than a cone might be something like a capsule collider but with spheres of different radii at the ends. This is like a soft cone and could be implemented efficiently as a sphere along a line with the radius a function of distance. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Another option is to allow the cylinder shape to have different top and bottom radiuses. This is what KHR_collision_shapes does in its cylinder definition: https://github.com/eoineoineoin/glTF_Physics/blob/master/extensions/2.0/Khronos/KHR_collision_shapes/schema/glTF.KHR_collision_shapes.shape.cylinder.schema.json This would mean that you can make a cone by using a cylinder with one of the radiuses set to zero. However, I am not sure how common it is to need tapered cylinders. Also we should get @jrouwe involved in this discussion. What is the best way to represent cone physics shapes in Jolt? Is it just a convex hull approximation? Alignment with Jolt may be helpful to drive a decision here. |
I don't think it is too difficult to add a tapered cylinder shape like the KHR definition above. Right now, you'd need to create a ConvexHullShape where the base has at most 16 vertices. |
B.t.w. looking at the pull request: I think a tapered cylinder shape would be better than the cone shape that is implemented in the PR since it is more flexible. |
The tapered cylinder shape has been merged into Jolt, so it should be possible to make an implementation in godot-physics+godot-jolt for this feature now. cc @mihe so you know what may be coming. |
Describe the project you are working on:
This is a project I came up with while thinking of use cases for such shapes, since I already opened my PR to solve this. I came across godotengine/godot#2138 and godotengine/godot#17252 and decided to expose it myself.
A very simplified flight game in which the player steers a plane.
Describe the problem or limitation you are having in your project:
The crowns of the trees in this game would be cone shaped. Since I need more precise collisions than cylinders or other shapes for the plane to be able to collide with the trees accurately, I can not use any of the other internal collision shapes.
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Exposing cone shapes would ease the access to this shape and would completely solve this problem.
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
See my PR in godotengine/godot#37199 which exposes it.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
Yes, one could generate a cone shape from the mesh of the tree crown or write a script that generates it. This would however not be as optimized as bullets cone shape.
Is there a reason why this should be core and not an add-on in the asset library?:
Yes, as this should belong to the already existing collision shapes. It is however possible to implement this as an add on, but I'm not sure if this shape can then be selected in the CollisionShapes 'Shape' drop down menu.
The text was updated successfully, but these errors were encountered: