> Yeah don't do that. I was talking about creating obstacles to block paths so the player has to go a different way. You said you tried this, but you were walking through the obstacles. It's because the player cannot see them, you need to regenerate the obstacle path at the point of creating the obstacles. The player will then find a new path as the previous ways will be blocked.
>
Ah, I think you've misunderstood - it's not the player who's pathfinding, it's an object, also I said the issue was that I don't want the player to be stuck on the obstacles when made solid for objects that pathfind
> I think you should check if you have added a Solid behavior to your obstacles and make sure Solids are assigned as obstacles in the Pathfinding behavior.
> The random numbers that are generated will determine witch obstacle's solid behavior will be turn from Inactive to Active.
>
> There is something you can do :
> - put obstacles on your stage
> - design different (let's say, 5) possible paths that are determined by a different combinaison of obstacles. Put the corresponding set of obstacles in different families named (for exemple) pathObstacle1, pathObstacle2, pathObstacle3...
> - for every moving object, before path is calculated, select a random family and put it as an obstacle in the Pathfinding behavior
> - calculate path
>
> Should be something like that :
> + System: For each MovingObject
> -> MovingObject: Add Pathfinding obstacle Obstacle(random(1,5))
> -> MovingObject: Find path to (targetx, targety)
>
There is no way to add a random obstacle in Construct 2, you need to select a single family/object.
I tried to work around it by assigning a variable to the moving object when it's created and having the path be set for the object depending on that variable, but that creates a myriad of issues...
Here's what I've done:
+System: On MovingObject Created
->MovingObject: Set path_number to round(random(1,6))
+System: For each MovingObject
->MovingObject: On path_number = 1
-->MovingObject: Add Pathfinding Obstacle: path_obstacles1
-->MovingObject: Add Pathfinding Obstacle: tilemap_walls
-->MovingObject: Regenerate Pathfinding Obstacle Map
-->System: Wait 1 seconds
-->MovingObject: Find path to (goal.x, goal.y)
+System: For each MovingObject
->MovingObject: On path_number = 2
-->MovingObject: Add Pathfinding Obstacle: path_obstacles2
-->MovingObject: Add Pathfinding Obstacle: tilemap_walls
-->MovingObject: Regenerate Pathfinding Obstacle Map
-->System: Wait 1 seconds
-->MovingObject: Find path to (goal.x, goal.y)
etc.
Any ideas on what I'm doing wrong?
And it works ?