How do I use pathfinding?

Get help using Construct 2

Post » Tue Apr 08, 2014 2:42 pm

Hey guys,

I'm kinda new to C2 and would like sumone to explain to me how to use the pathfinding behaviour. Can i make the enemy to find his way to the player? How?

Thanks,
Ashwin
B
15
S
3
G
1
Posts: 111
Reputation: 1,664

Post » Tue Apr 08, 2014 3:42 pm

The easiest way is to start a new project and select the Turret Defense template. It has a pre-built pathfinding example you can play with.
Visit me at EgoAnt.com
B
51
S
7
G
7
Posts: 78
Reputation: 6,408

Post » Tue Apr 08, 2014 4:26 pm

Supposing that you already know how to add behaviours to objects, the basic idea is this:

EventSheet

- make your object find an endpoint (there is always a start point and an endpoint even if you do fancy thinks like teletransportation o even a pathfinding loop, the start point is the actual x,y point where your pathfinder object is standing in the moment it starts moving towards the chosen path, the endpoint is the position you want your pathfinder to reach), it could be the position of another object or whatever you want depending on what you want to achieve. This can be achieved with the "find path" action.

- Use the on path found event in order to "tell" your object to start doing something the moment it finds the path toward the desired endpoint.

- In the on path found event use the action "Move along path" to tell the object to follow the path already found (pretty obvious maybe but just in case :P ) .
B
10
S
3
Posts: 75
Reputation: 864


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 35 guests