How to properly get the device's forward vector?

Hi! I'd like to apply a force on an object based on the camera forward (I use Device Tracking Surface mode). But I keep getting weird results where the object is going into the camera and not straight where the camera is looking at. Here's my snippet code at the moment:

var camera = script.getSceneObject().getParent();
var camForward = camera.getTransform().forward;
var dirForce = vec3.up().add(camForward).normalize();

physicsBody.addForce(dirForce.uniformScale(1000), Physics.ForceMode.Impulse);

see the GIF of the behaviour


  • I found out that .forward is positive z which is toward the camera in lens studio and -z (.back) is going away from it