Hello, from a certain version of the engine this script doesn’t work as it was doing previously, someone has some clue? It should delete the previous terrain created by heightmap and replace it with a new one (useful to change location in game)
changeTerrain: function() {
// disable all the houses
var house=app.root.findByTag('house1');
for(var x=0;x<house.length;x++) {
house[x].enabled=false;
}
house=app.root.findByTag('house2');
for(var x=0;x<house.length;x++) {
house[x].enabled=false;
}
house=app.root.findByTag('house3');
for(var x=0;x<house.length;x++) {
house[x].enabled=false;
}
// get the localMap value
this.lM=app.root.findByName('Player').script.player.localMap;
var img = app.assets.get(this.heightMap[this.lM]).resource.getSource();
var model = this.createTerrainFromHeightMap(img, this.subdivisions);
var collisionModel = this.createTerrainFromHeightMap(img, this.subdivisions / 2);
//var buildings = app.assets.get(this.dbTowns).resource;
//var oggdata = this.parseTownData(buildings);
this.entity.removeComponent('model');
this.entity.model=null;
this.entity.addComponent('model', {
type: 'asset'
});
//this.entity.model.castShadows=true;
this.entity.removeComponent('rigidbody');
this.entity.rigidbody=null;
this.entity.addComponent('rigidbody', {
type: 'static'
});
this.entity.rigidbody.friction=1;
this.entity.removeComponent('collision');
this.entity.collision=null;
this.entity.model.model = model;
this.entity.addComponent('collision', {
type: 'mesh'
});
this.entity.collision.model = collisionModel;
this.placeBuildings();
},