Jump to content

Checking collisions of the camera with the imported scene


Dimitry
 Share

Recommended Posts

Hello!
There is a small scene imported from 3dsmax: http://sitesman.com/3dcity/1/
There is a free camera there, what I am trying to achieve now is to disallow the camera to walk through the walls and objects. 
 
So the code goes like this: 
 
Scene.gravity = new BABYLON.Vector3(0, -9.81, 0);   Scene.collisionsEnabled = true;camera.checkCollisions = true;camera.applyGravity = true;camera.ellipsoid = new BABYLON.Vector3(1, 1, 1);Scene.checkCollisions = true;

Well and as you can see the camera goes through the walls. I feel something else should be done here, maybe I should create invisible meshes like squares and put them around the walls? Or what is the fastest method. Thanks!

 

Link to comment
Share on other sites

Hi,

 

 Nice scene. You need also to create some colliders and enable the collisions on them for that. Most of the time, we're using invisble box/meshes colliders. You can read my article to have a better understanding of what you need to do: http://blogs.msdn.com/b/davrous/archive/2014/11/18/understanding-collisions-amp-physics-by-building-a-cool-webgl-babylon-js-demo-with-oimo-js.aspx

 

 Basically, in 3DS Max:

 

 - create some boxes to match the various areas of your scene

 - make them invisible

 - enable collisions on them

 

Bye,

 

David 

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...