I have attached the code below for your reference while using this code i am able to move my object by clicking the object but unable to move by clicking the button which was kept by me inside the experience.
Requirement: I have Kept a button 3dui button inside my experience i need to move it to a point which is a 3dactor by clicking the button.
var cube1, cube2;
beScript.onStart = function () {
console.log("Hello, I'm executed at experience start");
// Debug: List available methods on 'this'
console.log("Available methods on 'this': " + Object.keys(this).join(", "));
// Check if the getActor method is available
if (typeof this.getActor === 'function') {
console.log('getActor method exists');
} else {
console.error('getActor method does not exist');
return; // Exit if getActor method does not exist
}
// Try to retrieve references to cube1 and cube2
try {
cube1 = this.getActor("Hi");
cube2 = this.getActor("senthil");
if (!cube1) {
console.error("Unable to find cube1. Make sure the name 'Hi' is correct.");
} else {
console.log("cube1 initialized successfully.");
}
if (!cube2) {
console.error("Unable to find cube2. Make sure the name '3D Actor' is correct.");
} else {
console.log("cube2 initialized successfully.");
}
} catch (error) {
console.error("Error retrieving cubes: " + error.message);
}
};
// Consolidated click handler
beScript.onUIClick = function (iEvent) {
console.log("Button clicked");
// Ensure cubes are initialized
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.message);
}
} else {
console.error("Cubes not initialized properly.");
}
};
// Removed the additional click handler to avoid duplicate logging
/*
beScript.onClickablePress = function (e) {
console.log("Clickable area pressed");
// Ensure cubes are initialized
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.message);
}
} else {
console.error("Cubes not initialized properly.");
}
};
*/
beScript.onStop = function () {
console.log("Goodbye, I'm executed at experience end");
};
