In the articles , I can see how I can make scoring in my game but I couldn't find how to limit the scores (limiting points that character gains). My game is based on points that my character gains but I want to limit those points and if he gains more than this amount , I'm trying to make game over.
I don't think there is a way you can do that without writing some code. Here is some code that should do the trick. 1) Replace your Add Point Code with this one 2) Add number Attribute name it "Limit" 3) Add an output signal name it "Limit Reached" Code: let callNameReset; let callNameAdd; let arg; let amount; //-----New Code------ let limit; let callNameGet; //------------------- function init() { let pc = this.attribute('Points/Coins'); let lg = this.attribute('Local/Global'); callNameReset = 'reset' + (lg == 'kLocal' ? '' : 'Global') + (pc == 'kCoins' ? 'Coins' : 'Points') callNameAdd = 'addScore' + (pc == 'kCoins' ? 'Coin' : 'Point') let ct = this.attribute('Current/Total'); arg = (ct != 'kCurrent'); amount = this.attribute('Amount'); //-------New Code-------- limit = this.attribute('Limit'); callNameGet = 'current' + (pc == 'kCoins' ? 'Coins' : 'Points') //----------------------- } function update(dt){ } function signal(name, value){ if(name == 'Enabled' && value){ this.scene()[callNameAdd](amount); //-----New Code------ if(this.scene()[callNameGet]()>=limit){ this.emitSignal('Limit Reached', true); } //------------------- }else if(name == 'Reset' && value){ this.scene()[callNameReset](arg); } } ----------------------------------------------- Our Youtube Tutorials
Thanks a lot for this . Much appreciated. Although I tried the steps you stated above, I couldn't make it. Still collects them in the amount I want but doesn't game over in the defined limited amount . The thing is if I choose only points (in add point node) my character gains them . When I choose coins it didn't work even . Besides that I checked my project settings and I made my score type points collected (I tried different variations with coins too however it didn't work). I attached a screenshot what I've done.
You missed step 2, you have no "Limit" Attribute 2) Add number Attribute name it "Limit" Click Add Attribute in the bottom right corner
Oh, you did. I was looking at the bottom of the list and didn't see it sorry. You have a Game Over listener in your Game UI and it's connected to Game Over UI, right? You can also try to put a Delay node before Remove because it might be deleting the entity before Defeat and Event have time to run, I was able to run without the Delay but that might be an issue.
yes, I have Game Over in my Game UI and it's connected to Game Over UI . I did that too but unfortunately it doesn't work. Thanks
You can try connecting delay and remove node with defeat node. That way, it is sure, defeat code finishes processing, before entity is removed.
Here, try this asset, it's from 3D Demo template, I modified the point to have the limit, you can place them in your scene and see if that works, I'm not sure why you having problems. Trying to be as helpful as I can.
Just thought of a nocode solution to this problem, just sharing it. Use the "Global Counter" node. Sometime a simple solution comes later.