How do I import a whole scene as a RigidBody3D?
Asked Answered
C

1

0

I'm currently working on physics enabled pick-ups in my game and have encountered an issue with the import process. Here's what I'm doing and where the problem occurs:

I import a model into Godot 4.0. I open the advanced settings window, select the mesh, enable physics, set the body type to dynamic, and set an appropriate shape type. I re-import.

I drop this imported scene directly into my level and attach a script to it that treats it as a pick-up. I also add an Area3D node so the system I've written for interaction can detect when I'm in range to take the item and show an appropriate prompt.

I hit play to test the level. I walk up to the pick-up, nudging it with the character's physics capsule. The object rolls away... but the attached Area3D node and associated prompt stay put. They should be attached to the physics object and roll away with it. What's happening is they're attached to the root node of the model's scene, which is a Node3D. The model itself is a MeshInstance3D child of the root and is moving independently.

How do I make the MeshInstance3D itself the root of the imported scene, rather than the current root? I've tried setting the scene root type to a RigidBody3D in the hope it will somehow pick up the collision data of the child MeshInstance3D and handle the physics simulation directly but, unsurprisingly, that doesn't work.

Capillarity answered 28/3, 2023 at 18:25 Comment(0)
C
0

The only thing I can think of doing at the moment is import the scene with the root set to RigidBody3D without any collision data, create an inherited scene off it, add a CollisionShape3D that's a child of the root, and set that up manually. Which seems needlessly over-complicated.

Capillarity answered 28/3, 2023 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.