Rhindon's Forum Posts

  • A while back, like, when Ashley first introduced the new Pathfinding behavior (I get chills remembering how awesome this introduction was at the time), I seem to recall the explanation that using too many Pathfinding objects all at once (even worse if the cells used for finding paths along were of different sizes) could eat up a lot of CPU.

    So, what I'm wanting to seek clarification on is how exactly C3 processes each object (rather, each instance of an object). I'm going to try to explain what I THINK I currently understand and then if someone could help me correct my (mis)understanding and/or add some info that could help me better grasp what's going on "under the hood" of this game's engine.

    As I understand it, each object with Pathfinding generates a grid by which the objects move, via nodes at specific cells. How this is done, I couldn't begin to guess...lots of math. Yes, certainly lots of math.

    I'm going to assume that instances of that object use the same exact grid as a means saving overhead on the CPU. There's no sense in generating a new grid to calculate movement on, I would think. (Unless, for some reason, it's necessary that each instance of each object with Pathfinding needs its own grid?)

    Either way, I think it's safe to say that the more objects with multiple active instances of Pathfinding is going to eat up a lot of CPU simply because of all the demands for calculating the path...especially when the cells are tiny (because that's a lot more precise of movement going on there around objects...it's more cells to account for). And the larger the layout, the larger the grid, the more cells...maaaaaaaaath.

    NOW, I know I'm probably going to need to be corrected on my assumptions above, but this leads me to my questions further on how to try to save on CPU demands when using any amount of Pathfinding.

    1. Does simply having Pathfinding assigned as a behavior to an object (enabled, but not actively being used) cause any considerable demand on CPU? Regardless of the number of instances of an object in the layout?

    2. Would destroying an instance of an object make a difference as soon as it's not needed?

    3. Is a grid generated per object using Pathfinding? Per instance of an object? Or does this grid exist so long as Pathfinding is at all assigned to an object even if it's not used in the project layout?

    I will try to set up my own tests to see what I can figure out, too, but those of you with a greater understanding of how C3 works in the engine, itself, your insight and understanding would be of great value to me. Thanks for your time.

  • That makes sense. Thank you, sir. I'll try to keep that all in mind. Hopefully I'll figure out something creative to manage the higher number of instances.

  • Ashley - Perhaps this will help me further understand the inner-workings of C3 so I can better manage how I set this game up...

    What are the - oh, let's say - five most CPU-demanding features of C3? Such as the use of Families, For Each, Picking, etc.

    There was a post by one Eleanor who was quite vocal about their opinion on what aspects of Construct worked faster (eg: Picking an object specifically by UID versus Pick All). So, I'm wondering if, however remote, this could help me refine my approach to large scale numbers of objects all running on one very large layout.

    It has been my understanding, further, that For Each literally runs through each instance of an object during that tick it is called on. Naturally, with hundreds, or even thousands, of objects, whether by Family (or perhaps more so because of Families), that's going to demand more CPU. But then again, generally speaking, For Each might not be so demanding. ... That's just an example of my weak understanding of things "under the hood" of this engine.

    I would estimate that this list, if you can provide me with such, won't always be objectively that way - it may shift depending on how the event sheets are set up and other factors. So, I'd expect such a list may be "on average".

    (I'll post this in the Discord channel, too, just in case you're not able to get back to me right away. I know you're quite busy and I always am grateful for your responses.)

  • A task, in of itself, for sure.

    I understand the difficulty in trying to help me isolate the issue but I'll see what I can do from what I've learned. Thank you, as always! :)

  • Hello!

    I'm working on a rather large-scale shoot-'em-up which will have an increase in enemies (and other related objects) that grows exponentially. I'm noticing in the debug that my CPU is topping out at around 95% (more or less) and dropping to 12 fps. Even after adding some checks that disable collision checking on non-essential objects, I'm still seeing upwards of 50,000 collision checks per tick with only 2500 objects.

    I was hoping I could get some tips on how to better manage (and lower) collision checks and speed up the game even when there is a lot of activity going on.

    If it helps, here is the .c3p file to review: https://drive.google.com/open?id=1hMqLnBz9wqTBQbRAEQD3hrdt2TdSEbfv

    Some things to note about what I have so far:

    - One enemy type generates up to 144 small sprites that fade away after a few seconds and destroys.

    - All enemy types can "replicate" themselves, which is how there will be so many very quickly.

    - A second enemy type will use another object to navigate a path it should take. This object that accompanies the enemy type uses pathfinding behavior. At present, I have not instructed the pathfinding to do anything, but it is enabled.

    - The layout is 8100 x 8100.

    - I'm using mostly sprites that range from 30 x 30 to 900 x 900 (and other variances of sizes along these values).

    - I have mostly 9patch objects for wall obstacles.

    - Movement behaviors are mostly limited to 8Direction, TileMovement, and Bullet. The aforementioned object that uses Pathfinding will be used in as limited a capacity as possible.

    Any thoughts or suggestions I could work on to reduce the CPU demand with so many objects and lower the collision checks even with a growing number of enemies?

  • You do not have permission to view this post

  • LOL That should have been so obvious to me by now. I'll test it on my end in the morning. Thank you!

  • It's hard to describe the issue so briefly in the subject line...

    Basically, the Pathfinding behavior of the Virus_DoorsAttk object (the attack type for the Virus_DoorsDef object) for some odd reason seeks out the lower-right corner SectorDefense object regardless of the starting point of the Virus_DoorsAttk. The origin point of the SectorDefense object is dead-center and the bounding box is uniform (octagon shape). The Pathfinding cell size is 5 while the SectorDefense object is 60x60. Even with no other objects in the way, the Virus_DoorsAttk object seeks the lower-right corner.

    The event lines in question start at line 153 (group "Blue Attack").

    Here is the .c3p: https://drive.google.com/open?id=1O4DTsJaHk33fSkghFSRU0gbQYxAScIC_

    Can anyone see why this is happening?

  • dop2000 - While waiting for a reply I continued to do some more digging and re-discovered exactly what you just said. So everything is working perfectly now. Thank you, though!

    However, I did not know about the Set Color action within the sprite, itself! Not sure how I ever missed that!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm trying to set an object to change its color after a random period of time. After such time, it changes to a randomly selected color (yellow, green, blue, or red). I'm using 3 variables on the object and then plugging those variables into an action that determines the values of the Set Color effect. Initially, all values are 0. After that, the only color I'm getting is red even though I've confirmed that the randomly selected color variable and the other color variables are all working just fine. It's the actual Set Color effect that's not registering.

    In the event line where I use the Set Color effect parameters, I have three separate actions for each color parameter of the effect - 0: red, 1: green, and 2: blue - and plug in each of the object's color-related variables to set the effect value. But, as mentioned, the only result I'm getting is RED. Am I doing something wrong when setting the values of the Set Color parameters?

  • Beautiful! Thank you, Ashley!

  • Aaaah! That makes sense. I've checked and rechecked the documentation many times before to see if I wasn't misunderstanding that...

    Is it possible to update the documentation to make this detail clearer? It's always been my understanding that the evaluations all took place in the text box and the operators were essentially use-as-everything-else (if that makes any sense).

    Anyway, I get it now. Thank you both!

  • Oh okay. So, in the text box I would type...

    "text1" | var = "text2"

    .... Correct?

  • I want to use the | logical operator symbol when testing the value of a string instance variable.

    If var = "text1" | "text2"

    However, when I try this, the expected outcome doesn't work.

    I checked the documentation page and it doesn't explicitly state that you cannot use string values but only references numbers.

    Am I correct that | only checks for numerical values and not string? Or is there something else I'm doing wrong?

  • Those uppity triggers, man. You'd think they'd play by the rules. :P

    I think I'll try to adopt your rule about triggers, myself, just to save on future issues.