[SOLVED] Playcanvas crashing

Hello all, I was just testing out a new script when playcanvas crashed, not just the launch tab, but the editor and code interface tabs as well.

Here is the new code I was testing:

var Dummy = pc.createScript('dummy');
let moving2 = false;

// initialize code called once per entity
Dummy.prototype.initialize = function() {
      this.point4 = new pc.Vec3(0.5,0.5,0.5);
 this.targetPosition3 = new pc.Vec3 (this.point4.x,this.point4.y,this.point4.z);

   this.lerpedPosition = new pc.Vec3 ();


};

// update code called every frame
Dummy.prototype.update = function(dt) {
 while(this.entity.getPosition.x != this.point4.x && this.entity.getPosition.y != this.point4.y && this.entity.getPosition.z != this.point4.z){
  //if(this.app.keyboard.isPressed(pc.KEY_1)){
  // Lerp the current position and the target position
    this.lerpedPosition.lerp (this.entity.getLocalPosition (), this.targetPosition3, this.speed * dt);

    // Update the entity's position to the lerped position
    this.entity.setLocalPosition (this.lerpedPosition);
};
};
// uncomment the swap method to enable hot-reloading for this script
// update the method body to copy state from the old instance
// Dummy.prototype.swap = function(old) { };

// learn more about scripting here:
// https://developer.playcanvas.com/user-manual/scripting/

Here is the link to my project: PlayCanvas 3D HTML5 Game Engine
Scene is “Glacius”

1 Like

Did this only happen once? Playcanvas crashed for me literally all the time, like once every 10 minutes. I really dont think this has anything to do with the script whatsoever.

I guess this.speed is undefined.

But that wouldnt crash the editor or the code editor. I say its a coincidence. Lose internet for 3 seconds and it crashes. Not that big of a deal.

Looks like the while condition is always true. getPosition is a function not a vec3. The lerp’s alpha ie this.speed * dt, won’t change in a while loop.

2 Likes

It’s not a coincidence, playcanvas never crashes for me (we won’t talk about the time I didn’t know how to use clone)

I think it is, lemme check with some variables and stuff quickly.

Also further proof that it is the script is that I just got an error with that script, and that’s been the first time that the tab has loaded sense the issue occurred.

Yep, the issue was the while loop. Thanks a million dude.

1 Like