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
};
Console Logs
[INFO]: "Hello, I'm executed at experience start"
[INFO]: "Available methods on 'this': _path, name, activationState, initialized, inactivityConstraints, nbConstraints, _selfActive, selfActive, _autoListeners, _autoActorsListeners, _listenersNameSet, _mainTask, actor, script, parent, CATICXPActivable, _varName, scriptinstance, cube2, cube1, _eventTarget, onStart, onUIClick, onStop"
[INFO]: "getActor method exists"
[INFO]: "cube1 initialized successfully."
[INFO]: "cube2 initialized successfully."
The above mentioned program is written by creating a 3DUI button inside that a new script is created and written inside and this works for moving my button but the problem which i am facing is like i need to move other actors say A cube named Cube1 from a set position using vector3d(0,0,0) to Another Cube2 Say set Point Vector 3d (0,0,0) using the button click and my motto is to place multiple 3d actors to multiple set points using one button click . What i Need To know ? For this where should i create my script inside object like 3d button or a common template need to created?
How to do in Java Scripting?
The image depicts in some clear manner where i click my button my object placed in table should go to the 3d Actor Point. But instead my Button Goes to that Point. Need a Solution for this
