How do I get equal object creation despite lag

Get help using Construct 2

Post » Fri Jan 30, 2015 3:06 pm

Hi, all!

I have built here a slightly extreme example to try and work around something that I have been encountering - lag can make "Every X seconds" events skip, as seen here:
Image

In a "proper" game engine the logic and rendering can both go their merry ways so these bullets would all make perfect curves. Question - is there a way to do this in C2? Can we modify this .capx so despite lag or whatever the resulting bullet patterns will be smooth with equal distances between them (and not make more lag by doing something very cpu intensive).

Ideas welcome. (Actually I should probably crank the bullets up and submit this as another performance example to Ashley - since this one creates new objects all the time).
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Fri Jan 30, 2015 3:23 pm

i have no lag here, everything works very smooth.
to make your bullets come out right even with lag you should use delta time:
https://www.scirra.com/tutorials/67/del ... dependence
Read this:
yeah, i really like to say that you should "Read this:"
B
12
S
5
Posts: 138
Reputation: 1,490

Post » Fri Jan 30, 2015 3:30 pm

@EyeForcz - would you mind elaborating how dt helps with an "Every X seconds" condition? Because I really don't think it's going to help with that.

I'm also attaching an Extreme version with 3x the bullets so it should start to lag, and an illustration of what lag causes in this case - every gap in the pattern is a moment when an "Every X seconds" command was skipped:
Image

Eh, since he said he likes to profile things perhaps I can sneakily tag @Ashley into this and ask - what's the official solution?
You do not have the required permissions to view the files attached to this post.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Fri Jan 30, 2015 4:14 pm

I'm having an issue with an infinite vertical jumper, where when the player taps the screen, the character is sent 1200 pixels into the -y vector using the platform vector action. However, occasionally the character appears to not be sent the whole 1200 pixels, and the jump appears to be shorter than its supposed to. Wondering if this is somehow related to your topic - maybe there's a minor lag spike that negates some of the pixels the character is supposed to travel, making the jump shorter than its supposed to, etc.

Wondering if making the amount of pixels sent in the y vector should be 1200*dt, but I was under the impression platform behaviors were already dt.

Anyway, sorry for hijacking your post. I felt this was somehow relative to yours and I didn't want to create a new post.
B
10
S
3
Posts: 12
Reputation: 695

Post » Sat Jan 31, 2015 6:59 am

@nal1200 - I suspect it could be. And all the built in behaviours supposedly do dt by themselves, but there's certainly something off at times - one can test this for example by setting up an object that turns 90 degrees for a second, then waits a second, then turns again - over time it gets more and more skewed, due to little timing errors.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Sat Jan 31, 2015 12:15 pm

That's why you have to build a system to decouple it from fps. Dt works to an extend, but like you said in the turning example, you need to keep those loopholes in mind when you code it. So you could do the rotation like this: https://copy.com/f4EoDCM2a2LnffYG

In a similar fashion you can build a system that generates the right amount of bullets, no matter if your game runs at 1 or 60 fps and then moves them at the correct location (maths involved). Try to keep it simple of course, since a lot of bullets means a lot of calculation. I just don't see how the "every x seconds" can work in such cases (same for tower defenses for example).
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786


Return to How do I....?

Who is online

Users browsing this forum: eochranek, fearfulelephants and 20 guests