Jump to content

ArcRotateCamera onCollide event


ragingclaw
 Share

Recommended Posts

Hello BJS sorcerers, I am in need of your voodoo once again!

I am using an arcRotateCamera. I have some hidden boxes that I am using as colliders the camera can pass through.

Here is the lowdown:

  1. camera is outside of the party box
  2. camera is inside the party box so it makes a little love, does a little dance, and gets down tonight and sends a message to angular "im at the party" (true)
  3. camera leaves the party box. stops with the love making, no more dancing - it only cries itself to sleep, and sends a message to angular "i left the party" (false)

I am using .onCollide to detect the collisioins between the camera and other stuff. The hidden boxes do have checkCollisions = true; I get the logs for the true event, but I never get false.

some code for you to laugh at:

scene.executeWhenReady(function() {
    _scene.collisionsEnabled = true;
    var cam = _scene.activeCamera;
    cam.collisionRadius = new BABYLON.Vector3(1, 1, 1);
    cam.checkCollisions = true;

    cam.onCollide = function(collidedMesh) {
        if (collidedMesh.obj_type == "locations") {
            cameraAtLocation = true;
            console.log('cameraAtLocation', cameraAtLocation);
        } else {
            cameraAtLocation = false;
            console.log('cameraAtLocation', cameraAtLocation);
        }
    };

};

 

so to recap, I need to know when the camera leaves the collision if that makes sense.

Thanks you wonderful people!

 

Link to comment
Share on other sites

  • 8 months later...

@RaananW In your latest collision code, when collision with camera is detected, the camera will reposition itself to a new position (a mix between previous position and constraints). But if someone wants to let the camera go through objects and just receive a notification (as ragingclaw), is it possible?

EDIT: This question could be linked to

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...