VR city obj => auto collision? sanity check

omg, this is very exciting, I can’t wait to play with this

yes lol everyone is going to have to put up with my cyber-totalitarian aesthetic; it is the price of me organizing this haha

1 Like

Here is a couple of PG city model examples: https://playground.babylonjs.com/#4HUQQ#1481 and

1 Like

I’m going to take this one and add it to the vr starter kit; how can I quote you inside the sketch in the comments?

also currently working here to adapt it to the xr camera Glitch :・゚✧

        //https://playground.babylonjs.com/#5UJIE1#2 adapted from this playground
        //here we are doing some thinking about collisions
        scene.collisionEnabled = true;
        //this checks if we're in VR, then runs out enable collisions function
        function enableVRCollisions() {
          xr.baseExperience.camera.checkCollisions = true;
          xr.baseExperience.camera.ellipsoid = new BABYLON.Vector3(1, 2, 1);
          xr.baseExperience.camera.ellipsoidOffset = xr.baseExperience.camera.ellipsoid;

I seem to be teleporting through objects; I’m wondering if I need to create a smooth locomotion function to test if collision is really working. Is there a pre-packaged smooth locomotion option, or should I write it myself? Am I reasoning correctly here (or should you not actually be able to teleport through buildings)?

just a gentle nudge on the above (bc the hack night is tomorrow), if you don’t have time no worries, but wondering if I have to enable smooth locomotion (and if there is already code for that or if I have to write it myself) in order to get collisions in VR?

@RaananW will be back tomorrow so I bet he ll be right on time :slight_smile:

1 Like

The XR camera doesn’t check for collisions ATM, as (“officially”) you can’t move the camera constantly like you move a free camera. The XRCamera supports teleportation for movements, which only allows you to land on predefined meshes, which will allow a different type of “collision detection”.

If you implement your own movement, you can check for collisions using the collision system on each frame and update the camera’s position accordingly. Check the FreeCamera (mainly the function _updatePosition and collideWithWorld). There is already an issue to allow free movement using XR controllers, this is a part of this ticket.

I am trying to implement my own smooth locomotion; so, this seems like the first step.

I just found a really cool custom build of the mozilla vr emulator that has all the buttons and axes etc. (so I don’t have to set up debugging).

Once I get this working, I will move on to thinking about collisions in VR.

OK, I implemented my own sliding movements. When you say “check the freeCamera,” you mean go inside of babylon and check the free camera, right? bc in the documentation FreeCamera | Babylon.js Documentation I don’t see _updatePosition or collideWithWorld .

yep, check the code :slight_smile: those are private functions

1 Like

I’m going to try and see if I can do this myself ( :grin:) but I’m beginning to think VR collision is more and more important.

There are two immediate use cases:
(1.) Walking/sliding around the VR city, I don’t want to go through buildings.
(2.) I think that generating terrain and then being able to walk on that terrain is pretty important.

I mean this is metaverse-ish stuff; I think we should have it. It will help for creating actual virtual worlds that multiplayers can/want to explore.

This will be addressed soon. Will keep you updated.

1 Like

returning to aking about VR collision (asked in the messages, but those are not public)

sort of re-realizing how powerful it is…

here’s townscraper in VR, can’t wait to walk on those towers and high levels: https://twitter.com/delta_ark/status/1432210242251546624

This is already commited :slight_smile:

This is the PR - add support for XR Movement Controller by brianzinn · Pull Request #10410 · BabylonJS/Babylon.js (github.com)

and this is the doc page:

1 Like

I am trying this tn!

OK, very very interesting. I started using it, a couple questions now:

(1.) I could theoretically design an ability that lets me switch between “flow motion” and “teleport motion” right? Let’s say I want to flow around and then jump up a ledge.

(2.) I’m using teleportation mode and collisions, but I don’t seem to be able to jump “on top of” of an object, is there some easy way to achieve that? (or maybe I’m just doing that wrong somehow).

here’s the code I’m working with: Glitch :・゚✧

I’m trying to spawn myself on top of the structure to see if I fall through it, but my spawn code isn’t working either (no idea why):

      //doesn't work;
        // //spawn on top of tower;
        function towerSpawn() {
            xr.baseExperience.camera._position._x = -102.12776084288441;
            xr.baseExperience.camera._position._y = 276.5707864044311;
            xr.baseExperience.camera._position._z = 279.4056826505191;

I also tried implementing a ramp (“ramp”), but I can’t teleport on top of it or slide over it. Making it collidable kind of bounces you off it.

So, yeah, love the slidy movement, love the horizontal collision, trying to figure out how to make it so that I can move along the Y axis as well. (get Y-collision, walk on the towers above, etc.).

The collision system used in the movement feature is the same as the one used in a free camera. Try a free camera in your scene, tweak the camera’s ellipsoid, its offset, the scene’s gravity and so on, and it will work just as it works with a free camera.

to change the camera’s position on session init you will need to wait for a single frame to render, otherwise the camera’s position will reset. This can be overridden, but the better way would be:

        function towerSpawn() {       
1 Like

take a look at this now: Login • Instagram

pretty neat, right? thanks for the help with setting the position of the camera

I’m now on the forum trying to get some jump code, so that I can jump around the platforms (I think that when I turn gravity way down, this is going to be insane)

So, here’s my real question though: how do I make it so that I can teleport on top of something? Should I ask this question in another thread? I think that switching between smooth sliding and teleport is actually pretty important for “multi-level environments” (etc.). Can I do this on my own, or is this a babylonjs thing?

Let s discuss it there: Standard jump code (but for VR)