I have this code, and it is working fine until I reach 30 in x axis (camera only bug).
basically when I set user xyz is working fine with every new Vector()
, but when moving camera then you see it that doesn’t move when I set a value bigger than 30 but only jumping…
see bug:
interface Configs {
gapCharacters: number;
gapCamera: number;
duration: number;
position: Vector3;
}
const DEFAULT_CONFIGS: Configs = {
gapCharacters: 20,
get gapCamera() {
return Math.round((this.gapCharacters / 100) * 80);
},
duration: 0.3,
position: new Vector3(0, 0, 0),
};
const DATA = fetchData();
class PoliceClass {
static array: BaseItem[] = [];
copy: BaseItem;
constructor() {
this.copy = Scene.getItem("RoRhmt4V")!.copy(); // just create a police character and change the id here
PoliceClass.array.push(this.copy);
}
handleClick(index: number) {
if (!DATA[index + 1] || this.copy.opacity < 0.3) return;
toogleShow(index + 1);
moveCameraToCharacter(PoliceClass.array[index + 1]);
}
}
let reachedLevel = 0;
const mainCamera = Scene.getItem("6t6SYba3");
DATA.forEach((thisData, thisIndex) => {
const newPoliceClass = new PoliceClass();
const thisCopyOfPolice = newPoliceClass.copy;
thisCopyOfPolice.transition.moveTo(
new Vector3(thisIndex * DEFAULT_CONFIGS.gapCharacters, 0, 0),
DEFAULT_CONFIGS.duration
);
thisCopyOfPolice.input.onClick(() => {
newPoliceClass.handleClick(thisIndex);
thisCopyOfPolice.thought = mainCamera.transform.position.x
});
});
function fetchData() {
return [
{
id: 1,
title: "iPhone 9",
description: "An apple mobile which is nothing like apple",
},
{
id: 2,
title: "iPhone X",
description:
"SIM-Free, Model A19211 6.5-inch Super Retina HD display with OLED technology A12 Bionic chip with ...",
},
{
id: 3,
title: "Samsung Universe 9",
description: "Samsung's new variant which goes beyond Galaxy to the Universe",
},
{
id: 4,
title: "OPPOF19",
description: "OPPO F19 is officially announced on April 2021.",
},
{
id: 5,
title: "Huawei P30",
description:
"Huawei’s re-badged P30 Pro New Edition was officially unveiled yesterday in Germany and now the device has made its way to the UK.",
},
];
}
function toogleShow(index: number) {
PoliceClass.array.forEach((thisCopy, i) => {
const HIDDEN = 0;
const SHOW = 1;
thisCopy.opacity = index === i ? SHOW : HIDDEN;
});
}
function moveCameraToCharacter(thisCharacter: BaseItem) {
const coordTo = new Vector3(
thisCharacter.transform.position.x,
thisCharacter.transform.position.y + DEFAULT_CONFIGS.gapCamera,
thisCharacter.transform.position.z
);
mainCamera!.transition.moveTo(coordTo, DEFAULT_CONFIGS.duration);
}
Scene.getItem("RoRhmt4V")!.delete();