Quick help with auto pathfinding.

0 favourites
  • 2 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • 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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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. <img src="smileys/smiley17.gif" border="0" align="middle" />

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