I’m making a project where I’m trying to place a sprite in canvas over a 3D object in 3D space. The code attached to the sprite looks something like this:
update (dt) {
const position: cc.Vec3 = this.camera.getWorldToScreenPoint(this.target.position);
this.node.setPosition(this._canvas.convertToNodeSpaceAR(new cc.Vec2(position.x, position.y)));
}
While it works perfectly fine in browser on desktop, when I run it on mobile the sprite is significantly offset (the sprite in question is the white square crosshair and the target is the red cube):
Is this a bug or am I doing something wrong?
CameraToScreenTest.zip (241.5 KB)