This is not specifically a Unity toolkit question but more of a generic question on how to reference the engine to access the enterPointerlock and exitPointerlock functions.
When I try and access it from my TS class it outputs
this.scene.onPointerDown = function () {
if (!document.pointerLockElement) {
this.engine.enterPointerlock();
}
else {
this.engine.exitPointerlock();
}
};
But as you can see it’s undefined here:
I’m assuming this is specifically a question of the engine not in scope of the function any longer. Does anyone know how I can either access the engine using the toolkit so I can fix my issue or how to handle it from JS and what I’m doing wrong?
So it builds but I can’t access the functions with this code:
this.scene.onPointerDown = ()=>{
if (!document.pointerLockElement) {
scene.getEngine().enterPointerlock();
}
Produces this error:
TypeError: getEngine().enterPointerlock is not a function
at t.scene.onPointerDown (f:\Projects\Unity\myPro\Export\scenes\myPro.babylon.js:1790:24)
at e._processPointerDown (f:\Projects\Unity\myPro\Export\scripts\babylon.js:16:253661)