I have a doubt about this code
if (playerToEnemy.length() < this.radius && (playerState!=='dead' || playerState!=='hidden' || prevPlayer !=='hidden')) {
where do i fault?
I have a doubt about this code
if (playerToEnemy.length() < this.radius && (playerState!=='dead' || playerState!=='hidden' || prevPlayer !=='hidden')) {
where do i fault?
I’m guessing you want:
if (playerToEnemy.length() < this.radius && playerState!=='dead' && playerState!=='hidden' && prevPlayer !=='hidden') {
As it makes more sense (I’m guessing the context). If the enemy is within this.radius of the player and the player is not dead and the player is not hidden then do X.
Your original statement:
(playerState!=='dead' || playerState!=='hidden' || prevPlayer !=='hidden'))
This is always going to evaluate to true as even if playerState is ‘dead’, the whole statement is true because it isn’t == ‘hidden’. If the playerState is ‘hidden’, then the whole statement is true because it isn’t == ‘dead’.