Ambiera ForumDiscussions, Help and Support. |
|
[ 1 2 ] Page 2 of 2 |
|
|||||
|
Hi Dynamogames, A couple of ways how you can do that: 1. If you're using regular on proximity behavior attached to the object you mention, you can write current time to variable, and then on proximity action read it from the variable and write it to disk or store some other way;
Then on proximity you read 'current_timer_value' variable value. 2. Option two - check distance between player and the object inside timer behavior and save the value if it gets lower than the threshold. |
||||
|
Thanks @okeoke, I'm still trying to implement it, currently what I did was that I added the SetCopperCubeVariable line of code to the behaviour and then I set current_timer_value" |
||||
|
Then I set "current_timer_value" to a variable called "best_time" and then I save the variable "best_time" and I also added a behaviour "Before First drawing do something" such that the "best_time" variable loads every 100Ms. I also added a 2D overlay that displays the best_time variable ($best_time$). I am not sure but would this work? |
||||
|
I set current _timer_value to best_time on proximity to the object |
||||
|
If I understood you correctly, yes it should work, but there are some details: before first draw you read best_time variable from disk. Than as soon as on proximity trigger is triggered you compare best_time to current_timer_value. If current_time_value is less than bet_time, you rewrite best_time variable and write it to disk. Also you can't just $best_time$ since it's saved as integer. You can check the existing behavior for formating: var mins = date.getMinutes(); |
||||
|
@okeoke currently I tried what you did but it's not working, the "best_time" variable just shows 0 and I think for some reason CopperCube is not reading the current _timer_value variable so the best_time variable can't work properly. I noticed this because I created a 2D overlay to display current_timer_value but it's not displaying any number. I'll be glad to send the ccb file for you to inspect if you don't mind. |
||||
|
When I tested the game, I also noticed an error, "Script Reference Error: date is not defined", this might be the reason there is currently an issue. |
||||
|
Yes, you're right. I forgot how this extension works. Please find another example here, I've updated the script and tried to comment all new lines, so it's clear what they do: https://drive.google.com/file/d/... Remember to delete behavior_CountDownTimer.js from extension folder, before opening the .ccb file, or behavior will not be overwritten. Also let me know if you have any questions. |
||||
|
Thanks @okeoke, I've been able to set everything up but at first I didn't get how the best time value worked or how is it gotten. I was expecting the best time value to be in the format of the countdown timer like Best Time - "00:04". But asides that everything works perfectly, thank you so much for your efforts and contributions for me and making my CopperCube journey smooth so far. I'm so grateful, I'll be posting the link of the final game on the forum today, you can check it out to see how your effort affected the game. Again, thanks. |
||||
|
No problem, I'm glad you found it useful:) |
[ 1 2 ] Page 2 of 2 |
|