Here i have provided the code this code is working for the individual object (that is when i create a script for the object which need to move)but not for different objects in the experience the getactor() and get actorbyname() is not working for me when i write inside a button. How to write in button ui and how to make objects move to the points please help me ?
var cube1, cube2;
beScript.onStart = function () {
console.log("Hello, I'm executed at experience start");
// Debug: List available methods on 'this'
console.log(Object.keys(this));
// Try to retrieve references to cube1 and cube2
try {
cube1 = this.getActor ? this.getActor("cube1") : null; // Adjust according to actual method
cube2 = this.getActor ? this.getActor("cube2") : null; // Adjust according to actual method
if (!cube1) {
console.error("Unable to find cube1. Make sure the name is correct and the method used is correct.");
}
if (!cube2) {
console.error("Unable to find cube2. Make sure the name is correct and the method used is correct.");
}
} catch (error) {
console.error("Error retrieving cubes: ", error);
}
};
beScript.onClickablePress = function (e) {
console.log("click");
// Place cube1 and cube2 at specific positions
if (cube1 && cube2) {
try {
cube1.setPosition(new DSMath.Vector3D(0, -633.021, 952.071));
cube2.setPosition(new DSMath.Vector3D(985.719, 0, 1083.843));
console.log("Cubes placed successfully.");
} catch (error) {
console.error("Error placing cubes: ", error);
}
} else {
console.error("Cubes not initialized properly.");
}
};
beScript.onStop = function () {
console.log("Goodbye, I'm executed at experience end");
};
beScript.execute = function (context) {
// Your continuous execution code here
};
