How do I get equal object creation despite lag

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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:

    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).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • - 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:

    Eh, since he said he likes to profile things perhaps I can sneakily tag Ashley into this and ask - what's the official solution?

  • 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.

  • 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.

  • 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).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)