Quick help with auto pathfinding.

Get help using Construct 2

Post » Wed Jan 29, 2014 3:58 am

Okay, so I'm having trouble getting the enemy to move to the target on his own.

For testing purposes, I originally had it set up so he would move to position when I right clicked on the screen. It worked fine.

Then, I tried to set it up so he would do it on his own. I am getting odd results.

This is a turn based game. I want the enemy to move when his turn is active, which he does. It's just that he goes to weird places or stops halfway.

Here is a screenshot of the problem code.

Obviously, I would disable the code for right clicking so it doesn't interfere with my new code of him moving automatically. I just left everything un-disabled so you could read it better.



Like I said, it works flawlessly when I right click, but always gives mixed results when automated. He just doesn't go to the right place or stops half way. I really don't know why and hope that someone with some programming knowledge may know.

Also, I had to set up the auto code to a trigger once event or it wouldn't do anything.

So, does anyone know how to fix it so it works automatically when it's the enemy's turn?
B
82
S
30
G
35
Posts: 340
Reputation: 23,071

Post » Wed Jan 29, 2014 6:45 am

I took a break and came back to it. I think I figured it out.

I set up my end turn button so I could test it without moving the hero. I noticed that it tended to work better when I didn't move.

So, I suspected the problem was that the character was still moving when the turn was set to the enemy's turn.

So, I set up another condition that the hero's pathfinding speed had to be zero before the turn would switch over. This was actually in another part of the code, not in the picture above.

It seems to work now. I'll keep testing it though since I still have a few things to work out with the overall code, but at least this is working as it should now.

So, nevermind I guess.
B
82
S
30
G
35
Posts: 340
Reputation: 23,071


Return to How do I....?

Who is online

Users browsing this forum: sypher1987 and 5 guests