I have a question about collisions - let’s say I have a room with 4 walls and each wall is it’s own objects with collision detectors. Then I have a movable box that represents a character and I want it to collide with the walls - is there a way to provide mesh.interesctsMesh() with multiple meshes, so I don’t have to check for each wall? I tried Mesh.MergeMeshes() but then the whole room becomes a collider and it’s now possible to move.
// Edit
I tried to upload a screen recording but cannot as a new user
I think that example uses physics to check for the collisions? I have a sort of “top-down” scene where you move a box around. It’s working fine using
if (player.intersectsMesh(northWall) {
// do stuff
} else if (player.intersectsMesh(southWall) {
// do the same stuff
}…
I’d instead like to do
if (player.intersectsMesh([…list of meshes] or mergedColliders)) { … }
Hello, why not just simply do something like that:
var list = […list of meshes];
for (var colliderIndex = 0; colliderIndex < list.length; colliderIndex++) {
var collider = list[colliderIndex];
if (player.intersectsMesh(collider) {
// do stuff
break;// exit loop
}
}
Hey, yeah I have my char wrapped around in a box collider and it’s working great, but I have to check for every single object I add to the game manually (e.g. loop), even objects that are on the other side of the map unless I check the distance, which is kind of a bummer. Something like mesh.isInCollisionWithGroup(“nonWalkThroughMeshes”) would be fantastic
+1 to this topic.
Am trying to build a mindcraft like snapping function… where you can add one object on top of another easily… so am trying to detect collisions on mousemove during a drag event. Using this loop technique, I’ve got a mesh collision check loop happening on every mouse move! Loops in loops.
b