I was making a stamina script so that when player_stamina reaches 0 you wont be able to sprint until player_stamina reaches 100. But when the stamina reaches 1 it crashes.
Project: PlayCanvas 3D HTML5 Game Engine
Scripts:
Scripts\Player\Movement\firstpersonmovement
Scripts\Player\Nature\Health
I see you have a method called break
in health.js. break
is a reserved word in JavaScript, try renaming it to something else and see if that fixes the crash.
it may help to say that it also crashes the actual playcanvas site locally
You’ve written an infinite loop on line 41 in health.js
:
while (player_stamina != 100) {
canSprint = false;
}
player_stamina is not equal to 100 the first time this loop is called which causes the loop to be repeatedly called until the browser crashes. I recommend removing the while
loop.
what do you suggest that I put instead?
nevermind i have figured it out