Physics not working for first box

try this

  var createScene = function () {
  // This creates a basic Babylon Scene object (non-mesh)
   var scene = new BABYLON.Scene(engine);

  // This creates and positions a free camera (non-mesh)
  var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);

  // This targets the camera to scene origin
  camera.setTarget(BABYLON.Vector3.Zero());

  // This attaches the camera to the canvas
  camera.attachControl(canvas, true);

  // This creates a light, aiming 0,1,0 - to the sky (non-mesh)
  var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);

  // Default intensity is 1. Let's dim the light a small amount
  light.intensity = 0.7;

  // Our built-in 'sphere' shape.
  var box = BABYLON.MeshBuilder.CreateBox("box", {height: 2, width:2, depth:2}, scene);

  // Move the sphere upward at 4 units
  box.position.y = 4;

  // Our built-in 'ground' shape.
  var ground = BABYLON.MeshBuilder.CreateGround("ground", {width: 10, height: 10}, scene);

  // initialize plugin
  var hk = new BABYLON.HavokPlugin();
  // enable physics in the scene with a gravity
  scene.enablePhysics(new BABYLON.Vector3(0, -9.8, 0), hk);

  // Create a sphere shape and the associated body. Size will be determined automatically.
  var boxAggregate = new BABYLON.PhysicsAggregate(box, BABYLON.PhysicsShapeType.BOX, { mass: 1, restitution:0.75}, scene);

  // Create a static box shape.
  var groundAggregate = new BABYLON.PhysicsAggregate(ground, BABYLON.PhysicsShapeType.BOX, { mass: 0 }, scene);

  return scene;
};

?
I’m not sure i understand, it works here :slight_smile:

1 Like

Please try on mobile device

Which device are you using?
Does it support Wasm?

Latest Android 13 & Chrome for android:

1 Like

I have tried on android 11

If i load a sphere first its fine but box mesh or convex_hull is not working

(i cant upload a video)

for vite dev server is any config available?

Because i need to copy havokPlugin.wasm → node_modules/.vite/deps/ manually

Tested it on a Android 12 phone, indeed the box shape is not working correctly…
Can you try the MESH shape? it worked for me

I can’t help you any further than that i’m afraid.
I’ll CC the physics gods of the core team :smile: @Cedric / @carolhmj and @eoin if he have any ideas / time to check it out

I think they’re on vacation at the moment, i don’t know if they’ll be back by monday or not, so please have patience :slight_smile:

1 Like

Hmmm, my phone is Android 13 and it worked fine :thinking: What is happening on Android 11/12, is the box just falling through the floor? I’ll also ask around the team if anyone has an older Android to test :slight_smile:

@carolhmj
It went straight through the ground, tested again now on a Android 12 and it is working fine with the box shape… same phone, same PG…
I suppose it could have been fixed already with 6.18.0 & Update to Havok 1.1.4 by sebavan · Pull Request #14195 · BabylonJS/Babylon.js · GitHub

4 Likes

on android 11/12 still not working .But if i refresh the page 4-6 time its working .(but restitution not )