Obsticle map

0 favourites
  • 11 posts
From the Asset Store
Create your own adventure map with this easy to use asset pack.
  • Hi!

    I'm working on a Tower Defense game with the maze building mechanic. Currently I'm using the standart pathfinding behavier.

    When a player adds a new obstacle, the map should be recalculated. To do this I regenerated a region instead the whole map. But I fond out that the regeneration of the entire map is less laggy than than just its part. An event of regeneration the whole map takes about 7 ticks and an event of regeneration a region of that map takes about 20 ticks.

    Why is this happening?

    Is it a bug or I missing something?

    drive.google.com/file/d/1D2-NNABB3TvTt0wWUAbpk5DwzSbDsi0a/view

  • Both of your code sections are running every tick. Replace the "System mode=all and mode=area" conditions with triggers so that they only run once. A function would work well here.

  • calminthenight There is trigger condition above. The map regeneration runs every 0.5 seconds. I know this is too freqvently, but this is for demonstration purposes only. In a real game the player will do it himself. Here is full events sheet:

    Also I added a link to the .c3p file in the 1st post.

  • Every X Seconds is not a trigger event. Try using Every 0.5 call function "field change".

    Then put those events inside the function.

    Or use a timer that repeats every 0.5 seconds and use an "On Timer" Event.

  • calminthenight ok, I'll try.

  • I've changed the every x seconds condition to timer trigger. Unfortunately the result is the same. To regenerate the entire map is still faster than to regenerate the region.

  • How big is your layout?

    Without testing it myself it looks like you might be regenerating your map of (possibly 1920x1080) once vs regenerating an area of 256x256 1000 times. The latter would be slower.

  • Looking at your .C3P file the issue is clearly what I mentioned before.

    When you're in the "all" mode, you are asking the creep object to regenerate the entire 1920,1080 area. Total pixels = 2,073,600.

    When you're in the "area" mode, you are asking all creep instances to regenerate a 256x256 area around themselves. Total pixels = 65,536,000.

    You can test this by changing both events to "pick random instance" you will notice no change in the "all" mode, as this is the same calculation, and the "area" mode will be significantly quicker (same as "all" mode), as it is only doing a single 256x256 regen.

    If you change the "area" mode event to use a "for each creep" loop. You will get the same result as the original events in "area" mode.

  • How big is your layout?

    currently its 1920*1080, but at the other resolutions the result is the same.

    Simple Games the problem is I'm not sure if it is a bug or if I'm doing something wrong.

    calminthenight Looks like you are right, it depends on number of the creeps and the region size. I've changed the region to 16*16 and the bugs disappeared.

    But the event of regeneration the whole map still takes about 7 ticks and the event of regeneration a region still takes about 20 ticks.

    You can test this by changing both events to "pick random instance"

    But in the real game there are more then 1 creep, thats why I testing on 1000 instances. Unfortunately, map regeneration for 1 instance doesn't take effect for all the instances.

  • I think you are misunderstanding how the obstacle map regen works. Regenning the obstacle map a single time will work for all of the instances of the object with the pathfinding behaviour.

    Have a look at this quick example that demonstrates that. 1drv.ms/u/s!AkmrWgxeuxlKhJkNjxRTazHyU_pd3A

    If you want to make the regen more efficient you should only regenerate the obstacle map around the areas that have changed, not for each instance of an object with pathfinding. e.g. If you add a new obstacle at coordinates 100,100 then you only need to regen the obstacle map around those coordinates.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • calminthenight Thank you! With your help, I finally figured out how obstacle map regeneration works. This way there is no bugs and the behavior works as expected with the correct events.

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