Feature request: prevent teleporting through walls

@RaananW

Currently the WebXR teleportation feature casts a ray beam through any mesh, allowing a player to ignore obstacles like walls and simply teleport right through them.

Would it be possible to have a single boolean configuration to disallow casting a line through other meshes? So that the player is forced to cast on the visible ground that is in their line of sight, and force them to use open doorways. The player should still be able to cast an arc to another floor above them or below them as long as the beam is not obstructed by some other geometry.

Thanks!

Oh, that would degrade performance. The raycaster will have to check for every single mesh in the scene (practically making all meshes “pickable”. I wouldn’t recommend that. It is already technically possible - add all meshes that are not floor to the walls array.

I would prefer not to add this kind of official feature, as it will be expected to work well, and i doubt it ever will. Maybe, instead, I can find a different way of achieving this. Maybe some predicate function instead of the array

I see :thinking: , that makes a lot of sense. Thank you for the explanation.

Could you please elaborate on “It is already technically possible - add all meshes that are not floor to the walls array”.

What is “the walls array?” Is that in the teleportation feature? If it is… I don’t see a public API for it.

Oh, the teleportation has a list of meshes you cannot teleport through. It is a fixed array called pickBlockerMeshes that you can add when (re)creating the teleportation feature.

I think it makes sense to allow adding and removing those block meshes on runtime as well, I can add a the functions to do that (just like the add/remove floor meshes). will that work?

Ooo! That’ll do. I didn’t know that was there. I’ll try it when I get a chance (I’m building a maze and i’ll be better if people can’t teleport through the wall!) I can make a PR to add that to the documentation if you’d like. I think adding functions to add or remove the pickBlockerMeshes on the teleportation feature makes sense since we can just dynamically add or remove meshes as they enter the scene. Curious though, is there a reason why you didn’t expose the floorMeshes and pickBlockerMeshes as public attributes so we can set them directly?

1 Like

+1 for the ability to update the list of blockers in realtime. Worlds that are dynamic would definitely benefit from that.

1 Like

Quick update - [XR] allow adding and removing pick-blocker meshes for xr teleportation by RaananW · Pull Request #10194 · BabylonJS/Babylon.js (github.com)

2 Likes