Fire bullet rate, diferent in devices

Discussion and feedback on Construct 2

Post » Wed Jan 21, 2015 1:37 pm

Hi!!

I need the fire rate is some in all devices, but if the device is slower (mobile), the bullet rate is diferente:

is correct my configuration?


Thanks!!!
You do not have the required permissions to view the files attached to this post.
B
4
S
1
Posts: 25
Reputation: 400

Post » Wed Jan 21, 2015 1:49 pm

Hi !

Don't use a "every x seconds" trigger condition for this ; if the actual framerate is slower, or not a multiple, of your time, it's not guaranteed to run at regular intervals. It's not a flaw in the "every x seconds" block, it's just bad logic.
Use a timer you update every frame with dt to make sure events like that happen at a fixed frequency.

E.g in pseudo logic :

every tick >
timer -= dt
while (timer <= 0.0)
{
dostuff();
timer += interval
}

(this version ensures that if the frequency of the event is much higher than the actual framerate, the logic can run multiple times every frame ; this may or may not be desirable depending on the case ; change the "while" to an "if" depending on the requirement)
Image
Game Producer & Independent Developer - http://raphaelgervaise.com
B
24
S
9
Posts: 237
Reputation: 2,232

Post » Wed Jan 21, 2015 3:01 pm

Thanks!

Is correct this example?
You do not have the required permissions to view the files attached to this post.
B
4
S
1
Posts: 25
Reputation: 400

Post » Wed Jan 21, 2015 4:29 pm

Yep, much better !

Though you might want to change the "set timer to 0.2" to "add 0.2 to timer" ; otherwise you might be accumulating a small error every time it is time for fire a bullet, meaning the overall shooting rate will differ slightly depending on device performance.
Image
Game Producer & Independent Developer - http://raphaelgervaise.com
B
24
S
9
Posts: 237
Reputation: 2,232


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests