Hi!
Thanks, that did the trick. I now have:
Every tick - Set value of variable 'Accuracy' to (100/ShotsFired)*ShotsHit[/code:1n9b8ckm]
That should be it right?
Thanks again for your help!
- R
Hi,
I wouldn't use "Every tick" in this case.
Just add on every shot "1" to "shotsFired" and "1" to "shotsHit", if the bullet hits the enemy.
Whenever one of those values changes, call a function to calculate the accuracy.
For instance,
shotsFired = 10;
shotsHit = 1;
Accuracy = 10; //10 %
On "bullet" collides with "enemy"
-> Add 1 to "shotsHit" (makes it 2);
-> Call Function "calcAccuracy";
On "bullet" created
-> Add 1 to "shotsFired" (makes it 11);
-> Call Function "calcAccuracy";
On function "calcAccuracy"
-> Set Accuarcy "shotsHit > 0 ? 100/shotsFired * shotsHit : 0" //Short-if -> ("CONDITION ? TRUE : FALSE")
If the player has 0 shots fired and the function gets called, it would devide by 0 (that's whay there is the short-if to avoid that).