Hi, I am currently making an educational game, and the gameplay is that the player will need to collide with certain objects to increase score (10 in total) and access the information that will display once collided with. BUT the score must only be increased once per object while still being able to display the information to avoid spam colliding with one object only. How do I make the score increase trigger only once per object? Thank you so much!
Here is the link to my editor: PlayCanvas | HTML5 Game Engine
My current workaround does not increase my score anymore after colliding with one object (score remains at 1) . Here is the code that I am working with.
Fpmove.prototype.OnCollisionStart = function(result) {
// FOR OBJ SCORE
if (result.other.name == "ArimaongaObj"){
score = this.app.root.findByName("ScoreDisplay");
//this.entity.sound.play('SFXDAMAGE');
this.app.root.findByName('Crosshair').enabled = false;
this.app.root.findByName('infoArimaonga').enabled = true;
score_counter++;
score.element.text = score_counter.toString();
if (score_counter++){
score_counter = false;
}
}
if (result.other.name == "DwarfObj"){
score = this.app.root.findByName("ScoreDisplay");
//this.entity.sound.play('SFXDAMAGE');
this.app.root.findByName('Crosshair').enabled = false;
this.app.root.findByName('infoDwarf').enabled = true;
score_counter++;
score.element.text = score_counter.toString();
if (score_counter++){
score_counter = false;
}
}
};