The laserTest script is being destroyed for some reason. After some console.log's I have narrowed the destroying down to moving forward. So whenever the player presses “W”, the script will be destroyed sometime after.
I have tested shooting around just by rotating(only pressed “A” & “D” and not “W”) and it did not destroy the laserTest script. So it has to be something with moving forward. Currently I’m not doing much to move the player forward(see below).
var p = this.entity.getPosition(); this.movement.copy(this.entity.forward).scale(this.speed * dt); this.entity.setPosition(p.x, p.y, this.z); this.entity.translate(this.movement);
The whole laserTestGeometry entity is being deleted. Which is very strange because that entity is a child of the Player entity, which obviously isn’t being deleted because the player doesn’t disappear or anything. The laserTest entity is not being deleted although. The hierarchy goes Player --> laserTest --> laserTestGeometry. The only entity that is being destroyed is the laserTestGeometry entity.