#This or That Filter Help

18 messages · Page 1 of 1 (latest)

hazy pendant
night lagoon
#

There's a "Head Tilt Left-Right" asset on the asset library!

hazy pendant
#

I've tried everyting but it is not working still

hazy pendant
#

02:22:34 Unknown array type: Component.SceneObject

night lagoon
#

Is the error from the script in the asset?

hazy pendant
#

02:43:08 TypeError: not a function
Stack trace:
at onReset (GameLogic.js.js:16)
at <anonymous> (GameLogic.js.js:49)
at <anonymous> (GameLogic.js.js:51)

02:43:08 Component is not yet awake.
02:43:08 Rendering failed 5 times in a row. Please fix the Lens and hit “Reset” button on the Preview panel.
02:43:41 Unknown array type: Component.SceneObject

#

// GameLogic.js

//@input SceneObject[] scenes
//@input Component.ScriptComponent tiltScript
//@input Component.SceneObject finalScene

var currentSceneIndex = 0;
var results = [];

function onReset() {
if (currentSceneIndex < script.scenes.length) {
script.scenes[currentSceneIndex].enabled = false;
}
currentSceneIndex = 0;
results = [];
script.tiltScript.api.reset();
setTimeout(function() {
script.scenes[0].enabled = true;
}, 1000); // delay of 1 second
}

function onLeft() {
handleTilt("left");
}

function onRight() {
handleTilt("right");
}

function handleTilt(direction) {
results.push({
scene: script.scenes[currentSceneIndex],
direction: direction
});
script.scenes[currentSceneIndex].enabled = false;
currentSceneIndex++;
if (currentSceneIndex < script.scenes.length) {
script.scenes[currentSceneIndex].enabled = true;
script.tiltScript.api.reset();
} else {
script.finalScene.api.handleResults(results);
}
}

script.api.onReset = onReset;
script.api.onLeft = onLeft;
script.api.onRight = onRight;

onReset();

#

tilt head script: // TiltScript.js
//@input float leftThreshold = -30.0
//@input float rightThreshold = 30.0

var left = false;
var right = false;

function onUpdateEvent() {
var eulerAngles = global.scene.getCameraType("back").getTransform().getLocalRotation().toEulerAngles();

if (eulerAngles.y < script.leftThreshold && !left) {
    left = true;
    script.api.onLeft();
} else if (eulerAngles.y > script.rightThreshold && !right) {
    right = true;
    script.api.onRight();
} else if (eulerAngles.y > script.leftThreshold && eulerAngles.y < script.rightThreshold) {
    left = false;
    right = false;
}

}

function reset() {
left = false;
right = false;
}

var updateEvent = script.createEvent("UpdateEvent");
updateEvent.bind(onUpdateEvent);

script.api.reset = reset;
script.api.onLeft = function() {};
script.api.onRight = function() {};

night lagoon
#

`// GameLogic.js

//@input SceneObject[] scenes
//@input Component.ScriptComponent tiltScript
//@input SceneObject finalScene`

#

couls you please replace these couple first lines in the script?

hazy pendant
#

let me try it 🙂

#

❤️

hazy pendant
#

it's a great progress

#

the only problem i have is with the line script.tiltScript.api.reset();

night lagoon
#

what is the error?

hazy pendant
#

03:28:03 TypeError: not a function
Stack trace:
at onReset (GameLogic.js.js:19)
at <anonymous> (GameLogic.js.js:52)
at <anonymous> (GameLogic.js.js:54)

night lagoon
#

looks like tilt script has to go first in the scene hierarchy

#

maybe that function is not initialized yet