Hello, i’m trying to random generate the enemy, i mean i have the enemy entity set with 2 models inside (disabled) when the program start the enemy script before the initialize function has “this.enemy = Math.floor(Math.random()*1);” that should generate a number 0/1 (is that correct?) a check “if (this.enemy===0) {this.ename=‘orc’;}” and if 1 ename=‘goblin’ in the inizialize function “this.entity.findByName(ename).enabled=true;” and “this.model = this.entity.findByName(ename);”.
But it doesn’t seems to work. Any idea?
Math.random()
will give you a floating point number between 0 and 1. Then you could do something like
if (Math.random() < 0.5) enemy 1 else enemy 2
Tnx Vaois i try that and let u know
Ok, now works, the math.floor already give an integer so i had to point the math.random with 2 to have a 0/1 return, and it’s not this.entity.findByName(ename).enabled=true; but this.entity.findByName(this.ename).enabled=true;