Discord
Login
Community
DARK THEME

3D collision

How do I do 3D collision. I've tried many things but surprise surprise nothing works!

I kinda figured it out. I just made another shape where the player is located and used player.intersectsMesh(object). Just in case anyone else is stuck trying to do 3D collision.

how do I do it with Micro 3d

No idea, but babylon is better than m3d so i'd swap if i was you

I made an example in Microscript

init = function()
  
  scene = new BABYLON.Scene()
  scene.collisionsEnabled = true   //IMPORTANT!!!
  
  //You can use other than freeCamera but it's the simplest
  camera = new BABYLON.FreeCamera("camera",new BABYLON.Vector3(0,0,0),scene)
  camera.position.set(0,0.2,-5)
  
  
  light = new BABYLON.HemisphericLight("light",new BABYLON.Vector3(0,20,0),scene)
  light.intensity = 0.9
 
 
  box1 = new BABYLON.MeshBuilder.CreateBox("box1",object end,scene)
  box1.position.set(0,3,0)
  box1.scaling.set(1,1,1)
  box1.checkCollisions = true   //IMPORTANT!!!
  
  box2 = new BABYLON.MeshBuilder.CreateBox("box2",object end,scene)
  box2.position.set(0,-1,0)
  box2.scaling.set(1,1,1)
  box2.checkCollisions = true   //IMPORTANT!!!
  

end

update = function()
  

  //Does the collisions
  local moveVector = new BABYLON.Vector3(0, -0.0981 ,0)
 
  box1.moveWithCollisions(moveVector)

 
  
end

draw = function()
  
  screen.render(scene)
  
end

it's not perfect but nothing is perfect so...

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community