Nabu's Forum Posts

  • Hey fm4fanAT,

    Thanks, that seems to be the way. But I just made a stress test and found no improvement, CPU usage is the same. I set an instance variable for the sprites and a global variable for keeping track of checked groups. On sprite creation, I set the instance variable to the global and increment the global (from 0 to 2, so I got 3 groups of sprites). In the loop I filter the selected sprite to check with condition (if instance variable match the actual global) and increment the global. Before I tested every 0.6 seconds, now 0.2 with 3 times less calculation per loop.

    So it does not lower the total amount of calculations needed of course, but only better divide the amount during same time as before. It only decreases little stuttering that can occur when there is too much calculation in one big loop, by doing more smaller loops.

    Very good in theory, but few results in practice.

    Do you know other kind of optimization when it comes to large number of units ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Tilemap object is relatively well optimized for drawing or collision, as it is a bunch of rectangle polygons to check.

    So it should not be a problem. Thus optimization is very project specific. It would be great if you could provide a capx.

  • Hello,

    If you want random animation to be played when pressing the same key, just set :

    • On key pressed (whatever you want)
    • Set sprite animation to choose(animationName1, animationName2, animationName3)

    animationNameX being a string,

  • Hello,

    Your event "Is BasketTrigger overlapping Ball" is not set by instances, and only triggers the first of all the balls that overlap in the same tick.

    So you have to change it to :

    • For each Balls
    • is Ball overlapping with BasketTrigger
    • Add 1 to score

    Like in this : https://www.dropbox.com/s/zpe3495i84iz1uc/100balls-clone-fixed.capx?dl=0

  • Hello,

    I got a project with an essential "For each" loop that can be CPU intensive. I have to restrain it to every x seconds action instead of every tick to be comfortably playable at some level in the game. I was wondering how it is possible to divide, or allocate this loop into several ones. For example, I would like to check the first half of the picked instances in a tick, and the second in the next one. Or if I use "every x seconds", check the first half at t 0, the second at t 0.15 seconds, again the first at 0.3, etc...

    Any idea ? Did anyone ever come to this optimization ?

  • Great ! Thank you soooooooooooo much ! I'm very happy about this ! Thank you for your time !

  • Ashley,

    Here is another example to clearly illustrate what I would like to have in native Pathfinding behavior. It is done using the EasyStar.js porting made by Magistross, setting the diagonals to On and the behavior specific property "Corner Cutting" to Off. It is asynchronous, so has about the same performance than the native behavior, and it's cool.

    https://www.dropbox.com/s/75fa1tnmykzkbdn/PathfindingExample.capx?dl=0

  • Problem Description

    When the diagonals are enabled, there is a bug with some area configurations where you can't get out though you can get inside.

    Attach a Capx

    https://www.dropbox.com/s/qmtgtkr42mmmlbu/PathfindingBug.capx?dl=0

    Description of Capx

    A player with Pathfinding behavior, any click to find path and move. A tilemap declared as a custom obstacle for the Pathfinder. Blue dots are created to display the path nodes. Hit "space" to display the obstacle map.

    Steps to Reproduce Bug

    • Click inide the area in the middle right for the player to get in. See that it's possible.
    • Once you're there, click outside to try to get out, and see that you cannot.

    Observed Result

    The pathfinder can't find path in some situations and put path node right on top of declared obstacle.

    Expected Result

    You should not be able to get inside the area. And the pathfinder should not be able to put path node on declared obstacle.

    Affected Browsers

    • Chrome: (YES)
    • NodeWebkit: (YES)

    Operating System and Service Pack

    Windows 7 64bit SP1

    Construct 2 Version ID

    Realease beta 226

  • Thank you for reply

    So it is impossible to get right path with pathfinding and cell size the same as tile size ? I don't really understand. In the example the tiles in diagonals in the walls are marked as obstacle, even with -1 cell border.

    Also, as you can see in the example, the pathfinder put nodes right on top of declared obstacles. I think it's actually a bug. I modified the project file in example and added a enclosed zone to the right of the layout. See that you can go in there (Pathfinder put a path node on a declared obstacle), but you cannot go out from there.

  • If some other people get stuck with the problem, I came with a backup solution. The problem is to keep objects moving in diagonal but also to not find path between two close diagonal tiles.

    Use the Pathfinding behavior with diagonals off, only to find a path and avoid setting path between two diagonal tiles. And for the movement, use another behavior and regularly test if the next node on the path is in line of sight or directly reachable via raycasting or whatever. If so, then set the object to follow on with this next node.

  • Hello,

    I found the possibility in Construct 2 to have multiple Pathfinding behaviors for the same sprite or family, and different Pathfinding behaviors with different name for different objects. This actually seems to do nothing cause there can be only one (Highlanders !!) Pathfinding behavior at a time. For example, if you use multiple behaviors and set different obstacles for each one, only the first object or family declared as obstacle will be record and apply for all objects that use a Pathfinding behavior.

    So why do we have this possibility in the editor that does nothing ? It would be really cool to have multiple pathfinding behaviors, with different obstacle maps for some projects.

    A capx that illustrates the problem :

    https://www.dropbox.com/s/rop1x9ysydnqb9c/PathfindingProblem3.capx?dl=0

    A link to a closed bug report about the same problem :

    https://www.scirra.com/forum/viewtopic.php?f=152&t=166387&p=1004339&hilit=pathfinding+different#p1004339

    I really think the Pathfinding behavior should be improved. Also there's problem with the diagonals that some other people mention in the forums. My bug report on this : https://www.scirra.com/forum/viewtopic.php?f=151&t=170406

    Ashley, please, can you do that ? It would be so great !

  • Problem Description

    Pathfinder find path where it should not, in in the diagonals.

    Even an object with a size of 1x1 could not pass and follow the returned path.

    Attach a Capx

    https://www.dropbox.com/s/ta0lowufer55sm6/PathfindingProblem2.capx?dl=0

    Description of Capx

    Here's a little capx to display a pathfinding problem. Any click to move the red sprite. Try to go left or right and see that it can pass through diagonal walls. R to retry and space to display obstacle map.

    Steps to Reproduce Bug

    Just try to go behind the walls. In theory it's impossible because there's not space between tiles. Try to go into the enclosed area on the right and see that you can pass through wall, but you cannot find out path.

    Observed Result

    Object find path through walls hen diagonal movement is enabled.

    Expected Result

    Find good path, because the pathfinder leads the object to bounce against walls if piloted by physics or other movements.

    Affected Browsers

    • Chrome: (YES)

    Operating System and Service Pack

    Windows 7 SP1

    Construct 2 Version ID

    Construct 2 Release 223

  • Really ? Nobody ? I edited the link in the first post so it now displays the pathfinder nodes onscreen. This is a strange behavior.

    Please, I need help on this.

  • Hello ? Nobody ?

  • Hello,

    Here's a little capx to display a pathfinding problem. Any click to move the red sprite. Try to go left or right and see that it can pass through diagonal walls. R to retry and space to display obstacle map.

    https://www.dropbox.com/s/ta0lowufer55sm6/PathfindingProblem2.capx?dl=0

    Is this an intended behavior of the pathfinding plugin ? I use a cell border of -1 because otherwize the obstacles are way too large. And a cell size of 32, the size of the tiles. Why does the pathfinder ignore the size of the object that's moving, and make it pass through diagonals.