ayrin
November 12, 2018, 11:07pm
#1
Hi, i had this code that worked fine, now it doesn’t anymore, any clue?
The problem is that the old terrain is not deleted but is kept also when terrain respawn as the removeComponent doesn’t work
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);
this.entity.removeComponent('model');
this.entity.model=null;
this.entity.addComponent('model', {
type: 'asset'
});
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;
yaustar
November 12, 2018, 11:11pm
#2
Any error message? Anything in console? What do you mean by ‘doesn’t work anymore’?
ayrin
November 13, 2018, 9:39am
#3
No error messages. I put some beakpoint in code and it seems to work but when it run the old terrain isn’t deleted as it should, the rigidbody and collision body are removed but the terrain itself is always shown (before it vanished and haven’t changed the code) so i guess it’s something in the terrain from heighmap that doesn’t work as it should
yaustar
November 13, 2018, 10:28am
#4
Have you tried using an older version of the engine to see if it was due to changes? https://developer.playcanvas.com/en/user-manual/scripting/custom_engine/
ayrin
November 13, 2018, 10:45am
#5
Oh didn’t know about this feature, i can try that, where i can find the engine id that was running in july?
yaustar
November 13, 2018, 11:42am
#6
You can see the release version and dates here: https://github.com/playcanvas/engine/releases
ayrin
November 13, 2018, 2:19pm
#7
Thanks a lot @yaustar i will post the results by tonight (i hope)
ayrin
November 13, 2018, 4:56pm
#8
With the version 1.8.0 it worked fine with following no
I used
https://launch.playcanvas.com/396696?use_local_engine=https://code.playcanvas.com/playcanvas-1.8.0.js#
to test. In game when lunched use the m key to open the map click on the town of Foren or Rekdar and use fast travel button when the new terrain open the old one is there or it isn’t according to the engine version used
ayrin
November 13, 2018, 5:03pm
#9
Errata corrige it happens from 1.8.1 to 1.8.2 and following
ayrin
November 16, 2018, 9:17pm
#10
@yaustar i have to report this issue in feedback? or you already pointed the problem at developers?
yaustar
November 16, 2018, 11:07pm
#11
I don’t know if it’s an issue with the engine or the terrain library. TBH, as it’s not a PlayCanvas feature, you would be better off talking to the developer of the terrain library.
ayrin
November 17, 2018, 6:42pm
#12
I think it’s @will the developer of the terrain library