#Automatically adding collision to models in library

18 messages · Page 1 of 1 (latest)

swift widget
#

Hello!
Bit new to Godot and switched over from Unity. While I'm comfortable with coding I am not quite used to how godot handles their scripts.
I have a simple scene here with tiles in a gridmap, the models are of the GLB file type.
What I wish to do is that in my node3D library of all the models, I wish to add collision to all of them using code so I don't need to manually add this to each of them since I plan to make this very convenient for mods in the future.

I tried running a script inside the library main node, but it doesn't start up in the main scene since the library main node is not present there, so I added a GameManager scripts that runs the library nodes ready function in the main scene.
But what I am suspecting is that the library is not at all loaded with all their children when this happens, is there a way to preemptively load this library and all it's children or am I going about this the wrong way?

It's all static objects right now and none of them will have animation.

fallow locust
#

why not add collision shape to each asset piece.
since all of them are individual scene, you can just create collision shape for them in their individual scene.

swift widget
#

They are not all in an individual scene, they are all in one library scene.
currently I only have 6 tiles for testing, but by the end of this project we will have over 100 tiles and maybe about 200 objects that will get placed by the gridmap, so I would rather not have moders and myself do that manually if I could avoid it.

#

I might split it up into category libraries later and have each category library contain some models, but right now, it's just one scene.

fallow locust
#

how are you creation those tiles? blender?

swift widget
#

ye

fallow locust
#

in the mesh of every tile, just add '-col' at the end, it should automatically create a collision shape while importing the glb file

swift widget
#

oh, inside blender?

fallow locust
#

yes

swift widget
#

you mean like at the name of each mesh? "corner_Plane_002-col" for example

fallow locust
swift widget
#

testing this out

swift widget
#

hm...I tried just double clicking and adding physics to the object, but this is not the same thing as the collider?

#

this is within the model and then I reimported the model

fallow locust
#

you can also open the model as a scene

fallow locust
fallow locust