[SOLVED] Problem that makes position NaN

What kind of script error can cause the position of my entity to become NaN?

Vec3 {x: NaN, y: NaN, z: NaN}
x: NaN
y: NaN
z: NaN

That can happen if something you did a calculation with it was NaN or null/undefined. Probably a division as JS may turn null/undefined into 0.

So maybe I set the entity to a position of an object that not exist?
I don’t get any errors.

Had a quick check, it looks like it is most likely caused by being in a calculation with an undefined object. It doesn’t throw an error when it does this as it seems to be a valid operation in JS :man_shrugging:

The weird thing is, if I disable the this.startClimbing(); in the code below, the problem is solved, but the console.log(“CHECK”); is never showed. How is that possible?

if (inputIsReleased && !playerIsArrived && playerIsSelected) {

I found the problem.

When the player is jumping I set a jump speed. I use the jump speed also in the falling part. Because I forget to set the jump speed in the intialize, things went wrong when the player was falling before the player has jumped, because at that point the jump speed didn’t exist.

this.entity.translateLocal(0, -8 * dt, -this.jumpSpeed * dt);