Raycast not work in new version

hi
this work in ver 4.1 but not work in ver 4.2
https://www.babylonjs-playground.com/#BVG26D#10

There you go :slight_smile:
https://www.babylonjs-playground.com/#BVG26D#11

The issue is the new architecture of the math-objects (vector3, quaternion). You used to be able to simply provide an object with x,y,z values (instead of a full vector object) and basic math (add, multiply) would have worked. This is no longer supported in the new architecture (at least not the way it was done until now with x,y,z). So this:

var tar = {x:camera.getTarget().x*1.-pos.x,
    y:camera.getTarget().y*1.-pos.y,
    z:camera.getTarget().z*1.-pos.z};

becomes this:

var tar = new BABYLON.Vector3(camera.getTarget().x*1.-pos.x,
    camera.getTarget().y*1.-pos.y,
    camera.getTarget().z*1.-pos.z);
1 Like