Thanks for the help, I’m making progress but It still looks like something is going wrong somewhere. I’m not sure if it’s a bug with mesh collision or just something I’m still doing wrong.
For the terrain, I tried to I use the geometry2mesh() method and stored the mesh for the terrain, but I get the same problem where the collision zone doesn’t match the terrain, and instead it returns a collision as long as the projectile intersects this blue box that appears around the terrain in the scene composer
https://i.imgur.com/I9eKfFo.png
if(item instanceof Terrain){
Mesh mesh = terrain2mesh(terr);
mesh.getBound().setCenter(item.getWorldTranslation());
collidableItemss.add(mesh);
}
I tried a different method for the terrain that got close to working, but with that code the collision ignored the terrain’s height and always caused a collision with a Y-value of zero.
if(item instanceof Terrain){
TerrainQuad terr = (TerrainQuad) item;
ArrayList children = new ArrayList();
terr.getAllTerrainPatches(children);
for(int v = 0 ; v < children.size(); v++){
TerrainPatch tp = (TerrainPatch) children.get(v); //tried to use this instead of a geometry, but it also did not work
Geometry geom = (Geometry)children.get(v);
Mesh mesh = geom.getMesh();
mesh.getBound().setCenter(tp.getWorldTranslation());
collidableItems.add(mesh);
}
Aside from having issues with the terrain, I also cannot get a normal model like trees or rocks to return proper collision when using the mesh. The trees seem to have a collision zone too large, and the rocks don’t seem to have a consistent collision zone at all
ArrayList alist = new ArrayList();
alist = (ArrayList) findGeometries((Node) item, alist);
for(int v = 0; v < alist.size(); v++){
Geometry geo = (Geometry) alist.get(v);
if(!geo.getName().equals("tree:Impostor")){ //makes sure to not collide with billboard tree imposters
Mesh mesh = geo.getMesh();
mesh.getBound().setCenter(geo.getWorldTranslation());
collidableItems.add(mesh);
}
}
I turned terrain collision off for this example video to show the weird results with the world models.
if I switch back to using the original Spatial object as the collidable like I showed in my orginal post…
as opposed to how I’m doing things with the meshes now:
Mesh mesh = (Mesh ) collidableItems.get(i);
mesh.getBounds().collideWith(collidable, results);
… then the hitboxes match every model (and the terrain) perfectly on the server just like they usually would in single player- as soon as I do collision with the mesh, I get these weird results.
Does it look like I may be doing the mesh collision wrong, otherwise is this possibly a bug with mesh collision shapes?