Not to be outdone, I've just developed a method which allows for much faster iteration times with no code duplication. Initial testing on my Macbook Pro (early 2011) within the creator is performing 60 loop iterations in 0.082 seconds. The best part is my new method actually performs a full-stop of game execution while the loop is performed. While this isn't always desired, it is very valuable for designing table search algorithms, among other things. I still have some fine-tuning and testing to do, but I expect to have a tutorial up on this method shortly!
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
@domenius I'm looking forward to seeing what you have developed. RThurman came up with a spawn-the-spawner recursive loop and it was faster but I couldn't figure out how to use it in an actual project as it seemed to hang on devices.
@domenius I'm looking forward to seeing what you have developed. RThurman came up with a spawn-the-spawner recursive loop and it was faster but I couldn't figure out how to use it in an actual project as it seemed to hang on devices.
Spawning a spawner is very dangerous, I know a couple of people who were killed trying that, you need - at the very least - to be wearing protective clothing.
Not to be outdone, I've just developed a method which allows for much faster iteration times with no code duplication. Initial testing on my Macbook Pro (early 2011) within the creator is performing 60 loop iterations in 0.082 seconds. The best part is my new method actually performs a full-stop of game execution while the loop is performed. While this isn't always desired, it is very valuable for designing table search algorithms, among other things. I still have some fine-tuning and testing to do, but I expect to have a tutorial up on this method shortly!
Any chance someone could point me in the direction of a video tutorial for this?? I found one for before/after so many seconds but none for "every X seconds".
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
@BlueFanStudios Did you already read the first post in this thread, specifically the part titled "---EVERY X SECONDS TIMER REPLACEMENT---"? I don't know of a video but that explains it pretty well.
I read it but I couldn't quite get my head around it. Im a visual learner, videos are easier to understand.
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
edited March 2013
It's pretty much just setting a real attribute mod1 to 0.05 and then making a rule that fires every time mod1>self.time%1 (for every second). If you change it to mod1>self%4, if will fire every 4 seconds.
Great Post! Thank your for your input. I have one question though...
I create a rule using your method to make the bullet destroy in 3 seconds but it quickly destroy right after it fires. (Using this method to spawn the bullet is ok though.
Thanks for your help.
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
edited March 2013
@kentcheung2000@yahoo.com Which method are you referring to? And how do you have your Destroy Actor behavior set up? What does the rule look like?
P.S. You'll want to change your forum account name in your profile because using an email address with the @ symbol causes notifications to fail.
I am trying to replace all timers of my game, but i got problem, i need to start a countdown after 1 second, so i need for 60seconds to remove 1 from an attribute that controls a replicate behavior. The problem is that even that on my player it works almost fine and i manage to match it with the music, when i test it on device (testflight) the replicate behavior is very slow, not 1 sec for 60 seconds. i post my rules and i wish that somebody could help on this.
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
@glynius Let's take the replicate behavior out of the equation and talk about the timer. Are you saying that the timer isn't counting down seconds correctly on a device?
Also, is this the effect you are wanting?
.....Every 1 second ..........Decrease counter by 1
*Note that an Every timer automatically starts after the first iteration meaning that an Every 1 second timer will trigger at 1 second, 2 seconds, 3 seconds, etc., and therefore is already starting "after 1 second."
@glynius Let's take the replicate behavior out of the equation and talk about the timer. Are you saying that the timer isn't counting down seconds correctly on a device?
Also, is this the effect you are wanting?
.....Every 1 second ..........Decrease counter by 1
*Note that an Every timer automatically starts after the first iteration meaning that an Every 1 second timer will trigger at 1 second, 2 seconds, 3 seconds, etc., and therefore is already starting "after 1 second."
Yes @tatiang this is what i want to achieve, every 1 second decrease counter by 1. Unfortunatelly the way i did it is not precise, and i don't get why. Also i don't understand what is the difference if i setup the mod attribute to 0.02 or 0.05...does this affects the countdown? I apologize for my questions, i a not a programmer and probably i will never be, and if gamesalad wouldn't exist , i would never be able to make any app.
tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,949
@glynius Not to side-step your question (although I'm not all that comfortable with modding timers myself) but... is there a reason you're needing to replace all of the timers? If it works with timers, then use timers by all means.
@glynius Not to side-step your question (although I'm not all that comfortable with modding timers myself) but... is there a reason you're needing to replace all of the timers? If it works with timers, then use timers by all means.
i noticed that replacing most of my timers, the game runs smoothly, keep in mind that probably i have too many rules and pointless stuff on my project that i cannot clear out at the moment (i mean with my current knowledge), replacing animation behavior and timers (as much as i understand) the performance is much better. I wish that timers would work better because i find it real mess to have all this rules instead of a beautiful timer expression.
@CodeWizard - Any chance you could take a look at why the defualt timers don't use these or similar methods and thus do not work as well? These ways have been working amazingly for me, but they are more inconvenient. Thanks, - Thomas
Wowsers! @ORBZ, I didn't realize that the expression editor could read Boolean operators. This is really cool! (I didn't make it to the yellow actors yet. I was floored with "not( game.Increment )" in the controller actor).
Boolean logic at the expression editor level changes everything!
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Spawning a spawner is very dangerous, I know a couple of people who were killed trying that, you need - at the very least - to be wearing protective clothing.
Sounds excellent !!
I can see where this is all going, it's only a matter of time before someone comes up with a loop that iterates into the past.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I create a rule using your method to make the bullet destroy in 3 seconds but it quickly destroy right after it fires. (Using this method to spawn the bullet is ok though.
Thanks for your help.
P.S. You'll want to change your forum account name in your profile because using an email address with the @ symbol causes notifications to fail.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I create a gun to spawn bullet using the following method. It works fine.
if mod1(0.05) > self.timer%1
spawn bullet.
However, Inside the bullet, when I try to make the bullet to last for 5 second, for example. I run into problem
Move bullet
if mod1(0.05) > self.timer%5
destroy.
the bullet didn't move the the direction I want and it just flash at the same location...
Thanks for you help..
When self.Time>5
Destroy [actor]
If you're still having problems, I'd recommend starting a new discussion and sending me a PM with a link to it so I can continue to help you out.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Also, is this the effect you are wanting?
.....Every 1 second
..........Decrease counter by 1
*Note that an Every timer automatically starts after the first iteration meaning that an Every 1 second timer will trigger at 1 second, 2 seconds, 3 seconds, etc., and therefore is already starting "after 1 second."
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
- Thomas
every 0.1 sec
spawn the bullet actor
Now, when I try using your.
self attribute.
Mod1 - 0.5 - real
self.Mod1>self.timer%1
spawn the bullet actor
My bullets are only firing 1 per sec
I tried changing to self.timer%0.1 but nothing happens.
If anyone can help me out with this I will very much appreciate it.
Thanks.
BRUNKT.com
Follow me at: Twitter - Instagram
Games and Templates
Appstore
Change your mod1 value to 0.05 and retry. The mod1 value can not be larger than the modulus you are applying (%0.1) or the rule will never fire.
Hope this helps!
That totally worked. Thanks so much domenius, you're amazing!
BRUNKT.com
Follow me at: Twitter - Instagram
Games and Templates
Appstore
Thanks,
- Thomas
- Thomas
Boolean logic at the expression editor level changes everything!