How see if turret is blocking the enemy path?

0 favourites
  • 7 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • Hello I,m making a turret defende game and want to prevent a turret to be build when it is blocking the enemy path (pathfinding) .

    Im using a code to build in grid set build x to round((PosX - 0) / 32) * 32 and set build y to round((PosY - 0) / 32) * 32

    And not overlapping current turrets already build.

    Hope someone has a easy solution :)

  • construct.net/en/make-games/manuals/construct-3/behavior-reference/pathfinding

    On failed to find path

    Triggered after the Find path action if no path can be found to the destination, such as if it is surrounded by a ring of obstacles.

    On path found

    Triggered after the Find path action once a path has successfully been found to the destination. The nodes are now available via the NodeCount, NodeXAt and NodeYAt expressions, and the Move along path action can also be used.

    Check for a path when attempting to place a turret. Either use a temporary helper object with the solid behavior and place the turret on path found, or simply place the turret first and delete it on failure to find path.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • oosyrag

    The solid works realy well but my cpu is like 98% when i drag the solid around.

    So option 2 is less cpu heavy but don't show the user that it is blocking befor placement.

    Any other ideas how i can let the player know he can't place the turret?

  • Only check for pathing on a trigger when something changes (or make your own trigger with the trigger once while true condition), not every tick.

  • So you want to prevent the situation when turrets are completely blocking the path to the target, right? But if an enemy can walk around the turret - this is allowed?

    Recalculating the pathfinding map and path is the only option here.

    If pathfinding plugin is using too much cpu, make sure that the layout size is set correctly (not bigger than the level map), try changing pathfinding cell size.

    You can use EasyStarJS instead of Pathfinding - it's massively faster, but only works with tilemaps. So you will need to make some changes to your game to accomodate it.

  • dop2000

    Thanx for the reply!

    Would you recommand to use EasyStarJS above of pathfinding regardless?

    Is it possible to use the tilemap to place the turret?

    How do i select the first tile of the tilemap and detect of it is placed so i can place the turret on top.

  • I don't know your game, I can't tell if EasyStar will work for you.

    EasyStar plugin only finds path, you'll need to move the enemy with other behaviors like MoveTo. Also, it's grid-based, so it won't cut corners as nicely as Pathfinding.

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