alternative to every 0 seconds timer?
Franto
Member Posts: 779
In the topic about timer replacements, it says the fastest possible iteration is 0.02?
Is there anyway to make an expression that is every 0.00? Or is using the timer behavior to 0.0 seconds the only way?
The new expression is great for damage calculations and has reduced lag significantly even with tons of actors on screen. But it's not good with movement, as the character stutters due to the 0.05 minimum. With the 0 timer, the movement was smooth(but because the timer was memory heavy, in preview, the character would get stuck running in older versions of the creator when there was a ton of stuff on screen.)
Comments
How long would the gap be between iterations with a timer like this ?
What new expression ?
Where are you getting a figure of 0.05 from ? You've previously said the 'fastest possible iteration is 0.02' ?
Not sure what that sentence means ? A timer is not memory heavy, it doesn't use up any more memory than any other rule or behaviour (except for perhaps Spawn Actor which could add to the memory load).
You've not said what you are using to move your actors, I know it's a timer, but you've not said what the timer is timing, what it is actually doing, I am going to make a guess that you are using Change Attribute behaviour to incrementally move an actor ?
@Socks Yes, I meant to say, in another thread it was stated to use 0.05 for the mod1 formula, and that the lowest it could go was 0.02, but for my project, I went with .05 iterations for damage calculation of when player/enemy actors overlap with damage actors.
Yes, that is correct about the attribute, for movement, I used a every 0 seconds timer, and within the timer, where various rules, such as for If .LEFT is true and .RIGHT false, change attribute: linearvelocity.x to -200.
I don't know how your game is set up - so this is only really guesswork - but why do you need a timer at all, I mean why do you need to tell an actor to move left every 0.02 seconds . . . so for example if you hold down the left key for 3 seconds you would have told the actor to move left 150 times in those 3 seconds !!? It will move left with just a single instruction, once it's moving left it doesn't need to be reminded to do what it is already doing 50 times a second ?
Like I say, maybe I'm misunderstanding the question as I'm not sure what your game does, but I can't see the need for a timer at all on something like directional controls?
@Socks The timer makes sure the character goes through their self gravity in the form of "acceleration" downward. When I take out the timer and leave the rules as is, when press either direction, the actor will walk a little and just stop, even if you are holding it.
Without the acceleration gravity, the character moves in any direction fine, but can't fall, and thus when jumping flies and can't go down. Which is why the timer is needed to ensure that moving right and left is always possible when pressing a direction.
EDIT: It's a platformer, the method I used is based off an old tutorial. I didn't think it would need rework until I heard about the heavyness of timers. Now I'm trying to remember or find a better platforming method that is timerless.
EDIT2: NVM, just remembered the tutorials from another Gamesalad member that might solve this problem. Thanks for the help though!
You don't need a timer for acceleration to function.
I'd guess there is something wrong with the way you have your code set up, but you certainly don't need a timer to keep Accelerate and Change Velocity working.
@Socks I meant their "Gravity" is acceleration as theirs no timer on it, so its always on, instead of the in-game gravity.{Early on, somebody said not to use the in-built gravity, but I don't remember why now, is it drainy on resources?}
Without change attribute for velocity being under a timer, the character is slowed down by the always active acceleration to a stopping point. I'm thinking about putting an attribute that halts acceleration "gravity", but it might mess up the nature of some attacks, and remove the effect of "gliding" with some attacks.
I just used the constrain attribute for the velocity change found in another tutorial instead of change attribute, but now when the character activates their speed up, which ads additional speed to their direction, they are stuck at their walking speed due to constrain attribute. The speed up is still using the old timer system. As it was in the old ways, speed could be added using other techniques on the character.
I just remembered, there was another movement based behavior that allowed it to be additive for speed, not sure what it was though.
Not sure what that means, neither scene gravity nor Accelerate need a timer.
Accelerate will not slow an actor down, if the actor is slowing down then it is caused by something else.
@Socks I guess your right, something else might be slowing down the actor, there are so many behaviors inside a single playable character, that the scroll bar on the side is a small square instead of a long rectangle. Trying to figure out what I can remove that won't break other things.
About the gravity, I didn't use a timer on that or accelerate. I meant that the accelerate behavior in a downwards direction was being used as a pseudo-gravity.
While the movement behaviors where what was using an every 0.0 timer, to ensure that it overrides anything that builds up like accelerate, but this also prevented the character from having any acceleration in its movements.
EDIT: Hmm, it does appear to be the vertical acceleration is the cause of the slowdown. Without it, and the movement rules out of timer behavior. The character could move left or right as long as you pressed the button. But it didn't smoothly change directions like every 0 or constrain would ensure.
Guess I'll have to go back to timers for movements I guess, unless the "hyper loop" is something similar to every 0 timer?
If I make a hyperloop with the number of iterations being constantly erased to keep it from reaching max iterations, could this be a better version of the every timer at 0? Or is hyperloop used for something else?
/merged
No need to start a new thread... you're basically still asking about the same thing.
To be blunt: it sounds like you're going about this wrong. You're trying to compensate for really complex rules by changing a Timer (a very stable, reliable, simple thing) into a Hyperloop (a very confusing, potentially reliable, difficult thing). Why not simplify your rules and use a Timer once you have everything simplified?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang Yes, I will try to simplify the rules as much as I can. I really needed a timer alternative that works just or exactly like hte every 0 seconds behavior. Every other alternative I try breaks something else. I've been at this for the past 2 hours now with no good alternative found.
For example, I tried combining acceleration+velocity without using a timer, and for some reason, the energy bar started regeneration beyond its 100% capacity{it's something that constantly drains when you move, and rules are set to keep it from going over 100}.
I'm guessing the timer keeps refreshing something that is a condition to prevent the above problem.
Here is a screenshot. The old method was a timer holding a group of rules. Very large group, about 10-15 rules, with 5 for basic directions. Would it reduce the lag if I keep only the basic movements inside the group within the timer? Is it lagging because it goes through a bunch of rules every 0 seconds? I'm not sure if a timer is weighed down by the amount of rules it has within it.
I managed to solve it via creative use of the expression editor a few days ago. Not only that, but ironically enough, I managed to create the very thing I set out to do the first month I was here: recreate the "rocket" movement, with fully workin but fake momentum.{I had limited myself thinking I had to use the game engines acceleration, when I could just simulate it in another way.
Although, I still wish there was an alternative for the every 0 timer for other things. Anyways, thanks to all that tried to help, and I'm grateful for being introduced to the Mod1 expression and all the other innovative stuff members came up with.
I'm not sure if I posted this already but I undertook a "Study of Loops" a while back and you might find the examples interesting: https://forums.gamesalad.com/discussion/comment/381275/#Comment_381275.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang Thank you! I hope to learn from your works.
Would you say loops are best used for reading tables quickly, or are there any interesting applications for them one wouldn't think of right off the bat?
The Study of Loops was a collaborative approach to designing the fastest possible loop. Beyond what I presented there, others came up with Fast For Loops and HyperLoops which were much, much faster but also much more complex to implement. Basically, we were wanting to increase the speed beyond the standard Every 0 seconds Timer behavior... and we did.
I love the Loop Over Table behavior. It's easy to use and fast. Other interesting applications? Sure, you can spawn a grid of actors or add up numbers extremely quickly or check for available paths... in short, anything you can think of really.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang Excellent, and that collaborative effort payed off, otherwise, we'd still have just the timer as our only option.
Ah, those are some awesome uses you listed, I wonder what other interesting things can be made with a little creative thinking.