#Use the model of a StaticBody3D as its collision

1 messages · Page 1 of 1 (latest)

idle mantle
#

So I created a StaticBody3D to use as the level mesh, and imported a .blend file. But I'm struggling to make it have collision. I know I can add a CollisionShape3D, add a cube shape and drag it to fit but that's not what I want, I want to simply use the same .blend as the collision for the StaticBody3D. Is this possible? how?

odd gust
#

When you you look above the viewport (where the sun icon etc. are) there should be a mesh button when the mesh instance is selected.
There are optinos to generate collision shapes from the mesh there

idle mantle
#

so here's the problem

#

I have a StaticBody3D, not a MeshInstance3D

#

if I try to create a MeshInstance3D, the problem is that it doesn't let me select the .blend file

#

it seems to accept any format except .blend

#

but I want to use the .blend importing feature because it's awesome to save the model in blender and have it update immediately in the viewport

#

so idk how to do this

#

these are the file formats recognized for the "mesh" in a MeshInstance3D

#

if I set it to "all files" and select the .blend anyways, I get this error

odd gust
#

Huh, I guess .blend is opened as PackedScene for some reason.
I usually just export from Blender so I'm not entirely sure what's up with that.

idle mantle
#

I think this means I just can't take advantage of the .blend import feature which would be lame if so

#

if I open the "packedScene" the mesh seems to be called "ground" which is what I called it in blender

#

maybe I can select "ground" somehow?

odd gust
#

Yeah I guess it makes sense. The other export formats, too, contain mroe than meshes. They turn the blender objects into nodes.

idle mantle
#

sorry I misundestood

#

so is there anything I can do?

odd gust
#

Like if I export my player the blender armature turns into an armature etc. yea

#

With the formats I've used there was a way to grab the mesh, though an export setting menu, but I'll have to check how blend work myself

idle mantle
#

I guess I'll just use gltf for now

#

but if you find out I'd love to know

#

so @odd gust , with gltf, what should the node structure look like?

#

should the MeshInstance 3D be a child of a StaticBody3D?

odd gust
#

Yeah

idle mantle
#

wtf it doesn't let me select a .gltf file either

#

how do you do it?

#

er sorry, .glb

#

it's also imported as a PackedScene

odd gust
#

I usually just right click a .glb or .gltf and select NewInheritedScene. ...actually, maybe same works for .blend I dunno.

#

You can also doubleclick and you get an importer where you can tell Godot to extract a mesh or materials.

idle mantle
#

AHHHHHHHHHH

#

I can do that

#

but will the inherited scene update itself automatically when I update the .blend?

#

okay so what do I do after I open the inherited scene?

odd gust
#

I kinda remember having some trouble with that. With mesh not always updating. Reinport forces update I think.

#

Anyhow the inherited scene is a scene. So you can add w/e to it. I often override materials in them, add colliders, scripts etc.

#

You can also right click a ndoe to change it's type

idle mantle
#

oh

odd gust
#

Like if you want the root node to be a staticbody3d

idle mantle
#

so I add the collision into the scene?

odd gust
#

Oh that's weird... I have covnert there. Dunno why you don't.

idle mantle
#

bruh lmao

#

so weird

#

wait I don't see "convert" anywhere in your screenshot

#

ah

#

change type

odd gust
#

Yeah

idle mantle
#

I'm very confused rn

odd gust
#

What Godot version you have? Though I have no idea when the change type was added.

idle mantle
#

4.3 beta 3

#

but anyways I think I found the solution

#

if I double click the .blend in the filesystem

#

I get this window

#

and as you can see, I can change the "root type" to be MeshInstance3D

#

so now, this .blend is a MeshInstance3D when I drag it into the scene

#

is that useful?

odd gust
#

Oh I see! I'm on 4.2 stable. Maybe they changed it. Looks useful.

idle mantle
#

so what should my next step be now that this is a MeshInstance3D?

odd gust
#

Oh wait it changes the root right? So maybe root should be StaticBody3D

idle mantle
#

oh okay

#

there, changed

#

what now?

odd gust
#

As an example this is how I set some of my floors

idle mantle
#

I opened the scene and added a CollisionShape3D

#

how do I select "ground" as the collision shape now?

odd gust
#

Alternatively, if you don't wanna use a box col or some other simple shape, you can use this menu with meshinstance node selected to generate one that matches the shape of the mesh.

idle mantle
#

that's what I want yes!!!!!

odd gust
#

But I often use simple shapes when it makes sense, better performance.

idle mantle
#

I don't want to use a box shape as the collision

#

I want the model to be its own collison

#

because the idea is to model a full level in blender

odd gust
#

I see!

#

I usually make a bunch of pieces in Blender and design them to fit on a grid.
But designing whole levels in Blender sounds cool, too. Heard environmental artists often do that kind of thing.

#

Btw if you name a mesh inside Blender so that it contains "-colonly" it will be used for collisions only when imported to Godot.
Sometimes handy.

idle mantle
#

ohh yeah that sounds useful

#

@odd gust collision!!!!!!!!!!!!!!!

#

I understand it now, thank you!!!

odd gust
#

Hey no problem, the importing stuff in Godot is a little weird for sure!

idle mantle
#

one last question

odd gust
#

Also if .glb is wonky or won't update you can also try .gltf I think it's made around the idea of exporting the materials etc. and editing them separately.

idle mantle
#

I edited the .blend and godot succesfully picked up on it and updated the mesh, but it's not reflected in the viewport for some reason

#

if I launch the scene, the model is updated, but the viewport hasn't updated

#

do you know how to update it?

odd gust
#

I think there's a reload project option in the menu somewhere

idle mantle
#

damn

odd gust
#

Yeah Project -> Reload project

idle mantle
#

that closes and re-opens godot entirely

#

seems a bit hardcore lol

odd gust
#

lol yeah

#

I often get weird issues when importing stuff to Godot from Blender

#

Mesh not updating, or visual glitches that need restarting Godot. Or sometiems just reloading the 1 scene works.

#

And if I change like normal data or such, not geometry. SOmetimes Godot doesn't realize something changed and I need to hit the Reimport button on the resource.

#

It's a little fiddly sometimes.

idle mantle
#

yeah reloading the scene works

#

cool, thank you!

#

I'm not 100% sure about whether I should be making the entire levels in blender btw

#

it's just what I gravitate towards atm

#

my only gamedev background is that I make mario 64 romhacks and that's how I've always made my levels

odd gust
#

Ooh!

idle mantle
#

but making individual assets and placing them is probably more efficient idk

odd gust
#

I did a 9 months Unity course at a low-level school. I made entire rooms in Blender for my final project, which would generate these tunnels from the rooms.
I wasted a lot of time on the UV unwrapping. But if you keep separate meshes in Blender it's probably a fine way to do it, too.

So that's why I've done in in Godot instead of Blender this time. But hey w/e works.
I think the tile way is probably more efficient for bigger games yeah.

#

Though I guess you can also make copies of objects in Blender that share the same mesh data, which would work very similarly to usign duplicates of say a wall or floor peice scene in a game engine.

idle mantle
#

you can instance in blender yeah

#

like if you make a streetlight model and you use it all around the level

#

if you duplicate it with alt+d, it's instanced, and if you edit one of the streelights, you're editing all of them

odd gust
#

Yeah. I have very little experience with that workflow so I dunno how it works in Godot. Could be great, could be bad. No clue.

idle mantle
#

this is my most recent sm64 project in case you're curious (this is a video of a youtuber, who organized the competition I participated in, playing through it)

#

I modelled the entire office, animated all the charactes, etc

#

a friend helped me with the coding part, but I also handled a lot of the coding

#

now I wanna transition into real gamedev

odd gust
#

Whoa that's really cool!

idle mantle
#

thanks :D

#

the theme of the competition was "slide". he obviously meant a slide level like going down a slide, but I decided to be funny and interpret it as "powerpoint slides"