Phazorknight / Cogito

Immersive Sim Template Project for GODOT 4
MIT License
902 stars 101 forks source link

New surface material footstep system crashes on collisions with ArrayMesh #65

Closed Bezoika closed 8 months ago

Bezoika commented 8 months ago

I use qodot for my level building which uses an ArrayMesh for every level build. The second I try to move it causes a crash with the new system. I noticed it works fine on the demo scene so I'm assuming based on the information that it is only looking for normal MeshInstances. image

ac-arcana commented 8 months ago

I'll look at this ASAP. I love Qodot myself and intend to use it later. An array mesh is something I had not considered.

I'm at work so can't look at the code right now. For now if you just return null on that line it will probably prevent that crash so you can work on your Qodot maps. It will stop the system from working properly with the material dictionary though.

Also, regarding Qodot, what are your thoughts on how to support footstep materials through Trenchbroom?

Bezoika commented 8 months ago

All good, no rush, I took a look at the system a bit when i got the crash. Looks like a cool way of implementing it.

Also, regarding Qodot, what are your thoughts on how to support footstep materials through Trenchbroom?

This really shouldn't be too much of an issue, as if you add a .tres with the same name as the texture that trenchbroom uses, it will automatically replace the texture with the material when the map is built in godot. Add said material into the step system and it should work fine.

ac-arcana commented 8 months ago

You're definitely right this is due to an array mesh. I'm able to prevent the crash and tell when it is an array mesh with the following:

image

No idea how to get the right materials from an array mesh yet though.

I can get some information about the first surface, like for example the name of it. I'm not sure how I'm going to find the right surface out of all the surfaces in the ArrayMesh.

ac-arcana commented 8 months ago

I'm not sure that getting the right material is going to be possible. Currently, I'm just getting the first material I can find from a collider. This works fine for small models, but when the entire map is one static body this poses a problem.

Since I am relying on collision data, what I am getting back is the static body. From there I find the array mesh. The trouble is polling an array mesh to find out what surface would be at the collision location and its material. This is beyond my expertise and I'm not sure that its possible. I don't really know how to go about trying to solve it.

I can provide an update to fix the crash and just play a generic sound instead for now.

Bezoika commented 8 months ago

I see, that stinks because i really liked the simplicity of it. I don't know if this would be helpful or not, as its kind of older but he states that it takes into account models with multiple materials so I don't know if this would work or not, but the code is way over my head so I figured I might just link it to you and see what you think. https://www.youtube.com/watch?v=WhMfocT9l-o

Whether it helps or not, thank you for making the bypass.

ac-arcana commented 8 months ago

I'll def take a look, and I will do some more digging into docs to find some kind of alternative at least. I'm determined to use Trenchbroom

ac-arcana commented 8 months ago

I got to look at the video now. It looks like it might work, I'll definitely dive deeper into the technique he used and try it out. It's gonna take a bit of time for me to really dive in though. It's a very busy week for me and next week I'll be away on a trip.

Bezoika commented 8 months ago

All good man, love to find out if it works but I'm in no rush, busy here too.