Nabu's Forum Posts

  • Hello,

    I was wondering how to make an AI for moving physics driven space ships. I thought of some things, like readjusting trajectory, compensating torque and trust, set velocity on target, etc... But I don't really know where to start. There gonna be small ships probably with dampeners to make them agile, and large ships with very different movement. Any suggestion ?

  • Hi maugiroe,

    The Construct 2 built in Pathfinding behavior does not work per instance, and has only one global map for everything. You have several add on plugins that may do this. I made a request for this but no answer yet.

  • Hello,

    rexrainbow, I'm doing some performance tests and I noticed that with your plugin I can decrease CPU usage of a heavy loop from 10/15% to almost 0. But it also increase the CPU usage of the C2 Engine. Is it normal ?

  • Hello,

    If you don't know the type of the target, you can create a family that includes all the targetable objects. And then you first pick the family by UID using the Turret Behavior's TargetUID, and try to pick one of the object with same UID.

  • Thanks 99Instances2Go, the plugin looks great. Hard to adapt an already existing project, but promising !

    Also thank you oosyrag for the advices.

  • blackhornet, I could make a little capx but it's more about ideas on optimizations for many units.

    Yes, thanks What I did and explained in my last post is very similar. But as I told it's very small improvement unless you have hundreds or thousands of units. It basically splits the amount of calculations, that remains the same, onto multiple smaller loops. Instead of having one periodic "big" stutter, you get small ones.

    I thought it could be a great optimization, but it's "only" a good little trick. Am I wrong ?

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

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

  • Try Construct 3

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

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