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

Improve/add new collision import options around indirect CollisionShape children (depends on godotengine/godot#77937) #11170

Open
funkysandwich opened this issue Nov 15, 2024 · 0 comments

Comments

@funkysandwich
Copy link

Describe the project you are working on

A game which would use modular assets to build levels and props.

Describe the problem or limitation you are having in your project

Currently, within the scene importer, you can enable physics generation on an imported MeshInstance node, and select a physics type. Rigidbody, StaticBody, or Area.

This will generate a separate physics object for each mesh you enable this option for.
This means there is no way to generate collision for several meshes under a single body.
image

This is also limited to generating CollisionShapes, meaning you can't import custom CollisionShapes that were created prior within a 3D modeling application as children of the visual MeshInstance.
image

If you want to generate only collisionshapes for a mesh, currently you would have to:

  • Create a new scene
  • Instance the imported scene and select edit children or make local
  • Select the mesh
  • Select Create Collision Shape

Since this scene is separate from the imported one, if I make any changes to the mesh externally and reimport, the collision would no longer match the mesh, and I would have to open the scene with the collision shapes, and regenerate and replace them manually.

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

Important: This feature would require godotengine/godot#77937 be merged in order to work.

  • Add a way to generate CollisionShapes and parent them directly to the mesh on import.
  • Also add a way to import a mesh as collision shape(s) instead, with the ability to select the shape, or determine the shape type on import from object names: For example, Unreal Engine allows you to prefix a mesh name with UCX_ (convex) UBX_ (box) UCP_ (capsule) USP_ (sphere) and _## for the index. like UCX_SomeMesh_01 will import as a convex shape for SomeMesh while UBX_SomeMesh_02 will import as a box scaled to the collision mesh vertices.

This way collision shapes will update on reimport and you can avoid having to generate them separately.
Another small improvement would be for imported collision shapes to be named after the mesh that they are for, instead of leaving all shapes named CollisionShape3D

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

Locally, I have the PR for indirect collisionshape children working, and I also tried making some changes to the importer:
Screenshot 2024-11-15 131014

Also, instead of changing the imported scene root type to a physics type, you could just add the imported scene underneath the physics type you want.
So you could reuse the same imported scene for rigidbodies, staticbodies, and areas.
Screenshot 2024-11-15 131410
Screenshot 2024-11-15 130924

You could also add several imported models as indirect children of a physics node instead of them needing to be separate bodies.
Here's how you could create a StaticBody for a room and it's props using this:
Screenshot 2024-11-15 132719

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

I'm not sure.

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

Importing scenes is core functionality in the editor.
This would improve the modularity of imported assets when using them as part of larger physics objects.

@funkysandwich funkysandwich changed the title Improve/add new collision import options around indirect collisionshape children (Requires #77937) Improve/add new collision import options around indirect collisionshape children (Requires PR #77937) Nov 15, 2024
@Calinou Calinou changed the title Improve/add new collision import options around indirect collisionshape children (Requires PR #77937) Improve/add new collision import options around indirect CollisionShape children (depends on godotengine/godot#77937) Nov 16, 2024
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

2 participants