Collisions detecting issue for imported meshes

I’ve imported 2 meshes from gltf files and tried to detect collisions but it’s not working. as you can see, I’d like to detect collisions sword with enemies.
I’ve research forum to find solutions but I couldn’t. I’ve attached some screenshots. Please help me.



Hey @Yura_Ivanov , welcome to the Babylon community! Maybe your sword model is not what you think it is, it is going to be hard to investigate without accessing the models. Is there a way for you to setup a playground so we can investigate?

1 Like

hi @srzerbetto Thanks for your respond. I’m fresh in Babylon.js so I don’t know how to setup playground for my Babylon.js project. If you can use Anydesk, you can see that issue on my local pc. I’ve my project on github. Can I share my git repo for you?

Unfortunately, I don’t think I’m allowed to connect to your local pc. The playground is very easy to use. You can add your logic there and hit “Save”, this will create a unique URL that you can than share here. Babylon.js Playground (babylonjs-playground.com)

The only caveat is that instead of loading you models locally; you would have to place them somewhere to be downloaded from the web (Such as Github), here is some documentation on how to do that: Using External Assets in the Playground | Babylon.js Documentation (babylonjs.com).

For your particular issue, it might be a good idea to try a simpler collider (such as a cube), instead of detecting the collision against a mesh. You can try adding a cube as a child of the sword and detecting the collision against that.

3 Likes

@srzerbetto I don’t think it’s easy to add my logic in the playground. so I share you my git repo

pls check it and let me know.

@Yura_Ivanov , I did a small playground using your assets just for the collision logic. I think you can use it as a starting point:

Sample Forum | Babylon.js Playground (babylonjs-playground.com)

3 Likes

@srzerbetto Wow! thanks very much.

1 Like

@srzerbetto I’ve a question. In your sample ground, you’ve used collision mesh imported gltf file and box. The collision is working well with imported mesh and shape box. but not working with 2 imported meshed from gltf files.
I have 2 imported meshes like this
const enemyCollider = BABYLON.SceneLoader.ImportMeshAsync(“”, “https://raw.githubusercontent.com/HumbleDev-1119/dungeon-babylonjs/main/assets/meshes/”, “deathknight.glb”, scene);
const swordCollider = BABYLON.SceneLoader.ImportMeshAsync(“”, “https://raw.githubusercontent.com/HumbleDev-1119/dungeon-babylonjs/main/assets/”, “longsword.glb”, scene);
I’d like to detect collision with enemyCollider and swordCollider.
Could you please help me once more? thanks.

Hey @Yura_Ivanov , how are you doing? As I said, sometimes it might be a good idea to detect collision against a sphere or a cube instead of a mesh, this will give you way better and easier to debug results. The solution for you would be to create a cube with the same size as the sword and set its .isVisible = false this way you will not see the cube but it will be used for detecting collision.

2 Likes

@srzerbetto oh. Ok. thanks for your help.

I would also recommend using AssetsManager:

Here playground example with your enemy and sword:

1 Like

@Takemura thanks. let me check

@srzerbetto Thanks for your help. I’ve done collisions with your help. I’ve other problems in ragdoll.
Could you please add ragdoll in your example playground?

Thanks.

Hey @Yura_Ivanov , what specific problem are you having?