Here is a way to allow players to walk infinitely in all directions as if there are no world boundaries:
Here is a Nova example but It works the same way in Edu:
The code is below. Just make a typescript document and then copy and paste everything below into it. You need to use a background environment that is flat and does not have stuff like trees, mountains or buildings in the distance for it to look correct.
It assumes your camera has the default name: “Camera”.
Code:
let camera = Scene.getItem("Camera");
let allItems = Scene.getItems();
allItems.forEach(item =>{
if (item.name.includes("#holder")) {
item.opacity = 0;
}
})
allItems = excludeItems(allItems);
function excludeItems(allItems) {
return allItems.filter(item=> {
// put #noMove somewhere in an object name if you do not want it to auto-move
return item.parent === null && !item.name.includes("#noMove");
});
}
Time.scheduleRepeating(()=>{
// allItems = excludeItems(Scene.getItems()); // Turn this on if you have objects generated or copied programmatically and not from manual placement
if (camera.transform.position.y > 25) {
allItems.forEach(item=>{
let itemP = item.transform.position;
item.transform.position = new Vector3(itemP.x, itemP.y -50, itemP.z);
})
} else if (camera.transform.position.y < -25) {
allItems.forEach(item=>{
let itemP = item.transform.position;
item.transform.position = new Vector3(itemP.x, itemP.y + 50, itemP.z);
})
}
if (camera.transform.position.x > 25) {
allItems.forEach(item=>{
let itemP = item.transform.position;
item.transform.position = new Vector3(itemP.x - 50, itemP.y, itemP.z);
})
} else if (camera.transform.position.x < -25) {
allItems.forEach(item=>{
let itemP = item.transform.position;
item.transform.position = new Vector3(itemP.x + 50, itemP.y, itemP.z);
})
}
},0)