In Depth event optimization questions.

0 favourites
  • 6 posts
From the Asset Store
A very simple to set up ZElevation based depth of field system for your game. Fully commented.
  • Throughout my project i have lots objects where their position is set every tick to the position to another object. Doing a little bit of testing turning off these particular event saves me a lot of CPU budget, but then again objects wont follow. It's not really the draw calls that make up for these CPU usage, but rather the setting of all the numbers every tick.

    I've read all the optimization guides but want to go more in depth on how to optimize the events as I'm aiming to make a quite complex game for Mobile so every tiny bit of CPU usuage i can save on seems like a very good idea. I've identified the "on every tick" event as a major resource hog. So....

    Will (Pin Behaviour) Pinning an object to another one instead of using On every tick > set position to > sprite.X sprite.Y or is there any other way that I've missed that might be better.

    I know we're talking minimal tiny ammounts of CPU per object, but everything adds up quite fast.

  • you could save time with each 0.xx sec, instead of each tick. try each 0.05 sec setting a position - it will give some relief to your cpu, but still it will be cpu intense. also there's another factor - if you use each tick - huge cpu usage, if you use each (let's say 1 sec) - you will see "jumps", instead of smooth following.

    i know for sure that cartoons run in 24 frames per second and they do look good, fluid. so try setting your options to 0.05 sec (0,04166666666666666666666666666667 s) for 24 frames following. the change should be invisible to eye, but it should give processor 3x less work to do.

    oh yeah - pin also works on each tick - so you've done nothing. funny thing also, if you have pathfinding with movable obstacles - use regeneration each 0.2 sec - worked perfect for me.

  • Another question. I would imagine that the structure of the events would play some role as well. For example... If you have an event, which is false, will any further sub-events be skipped by the system and not checked, or are they still run through and checked?

    I would imagine that using sub-events well could limit a lot of checks that way. If the first event is false & placing many related events within that one, instead of creating a new event under, with the same conditions would save on some quite a lot of checks?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • skipped. if you have

    something like this:

    if (a>0) 
         do something and then
         if (b>0) 
             do something else [/code:1fohblc6]
    
    each tick you check a>0    if it is true it checks b>0 and does events prior to it. if a>0 is false it skips the rest.  if b is false skips all under b and so on..
  • I'd be surprised if setting object positions every tick really is the cause of your performance problems - it's one of the fastest and best-optimised parts of the C2 engine. Can you make a new empty .capx demonstrating the performance difference so I can investigate?

    As for events, they are all run top-to-bottom and it stops running the event as soon as it comes across a false condition (unless it's an OR block). The C2 engine is not so poorly designed that it would do such wasteful work as running an event it already knows isn't going to run!

  • Strange - when I make a new project i don't get the same effect. Have to investigate further. In my project there is a group with events which keeps hovering around 1 to 1.5% CPU usage (mostly this group contains set position every tick on several sprites) even when all the events in the group is disabled - the group still uses around around 0.6% cpu... When i replicate in a blank project the same kind of events only take 0.4% CPU... and 0.1% CPU when disabled.

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