var rotationSpeed = 0.15; // Rotation speed in radians per frame
var rotationDuration = 1 * 60; // 3 seconds converted to frames (assuming 60 frames per second)
var rotationCount = 0;
var movingTowardsZ = false;
var movingTowardsGround = false;
var objectToRotate; // Define the object you want to rotate
beScript.onStart = function () {
console.log("Hello, I'm executed at experience start");
// Example: Retrieve the object you want to rotate by name or any other method
objectToRotate = this.getActorByName("Cube", true); // Pass "Cube" as a string, check recursively
};
beScript.onStop = function () {
console.log("Goodbye, I'm executed at experience end");
};
beScript.onClickablePress = function (e) {
// Trigger rotation when the clickable is pressed
startRotation();
};
beScript.execute = function (context) {
// Delay for 10 seconds
if (rotationCount === 0) {
if (context.elapsedTime < 20 * 1000) { // 10 seconds delay
return; // Exit the execute function if less than 10 seconds have passed
}
rotationCount = 1; // Set rotation count to 1 to indicate that delay is over
console.log("Delay over. Starting rotation...");
}
// Rotating the object for 3 seconds
if (rotationCount <= rotationDuration) {
console.log("Rotating...");
if (objectToRotate) {
var rotationVector = new DSMath.Vector3D(0.0, 0.0, rotationSpeed);
objectToRotate.rotate(rotationVector);
}
rotationCount++;
}
};
function startRotation() {
// Start the rotation immediately when the clickable is pressed
rotationCount = 1;
console.log("Starting rotation...");
}
