Waypoint gets drawn, character goes totally wrong way

Hi,

I followed the getting started guide to add pathfinding to my game tech demo. Everything went fine, grid is properly generated. And even waypoints are properly drawn but the character controller always goes infinitively downward.

Here’s my setup:

And here’s an example of a waypoint with the character going totally down:

Any idea of what’s happening? The character controller code is exactly the one from the guide.

Please :slight_smile: Thanks and have a nice day!

It seems to be a 2D game and your grid is X/Y, not X/Z with Y on the vertical axis like most A* example.

I’m not very aware of 2D games using A* Pathfinding, but search the forum, you will find interesting information, I’m sure your error is common.

Hi and thanks for responding.

X ,Y seemed logical for a 2D game. Want to move your character vertically? Use the Y vertical axis for example.

Also I searched the forums before asking and I did not encountered any other thread about this. Maybe I don’t know what to search. Any suggestions?

I tried changing the climb axis and it doesn’t change anything in that weird behaviour.

If there’s anything I can try please tell me.

Thanks for your response and have a nice day!

Hi

The default movement script (AIPath) does only handle XZ movement and assumed Y is up. To solve this, you can replace all .y with .z in AIPath.cs and all .z with .y.

Thanks for your answer, I changed as proposed the movement script and it didn’t change a thing yet. Is there anything I must clear/rescan for it to change? Because right now the character still goes down forever. Thanks for the help I really appreciate it :slight_smile:

Funny enough, I registered here to post this same issue. I have a setup using 2d toolkit and was trying to get my character to move, but he only wants to go negative on the Y axis.

The move graph is set up to be vertical on the x and y. Generation took some fiddling but I got it, and the whole thing matches my background image on Z exactly. Both at Z 0 position.

My character draws the path perfectly, but as in the OP, he only travels straight down. I too have implemented the suggested change in AIPath.cs but the behavior is the same.

Thanks for any help anyone can offer. I realize I’m coming in a week later. tbergeron, let me know if you managed to solve this.

Update: I figured out that it was gravity pulling the guy down off the map! Turned it off (edit->Project Settings->Physics) and things are better in that regard. But the problem now is that there is no movement at all.

Figured this one out and I now have a moving character!

The issue is that, for some unknown reason, controller.SimpleMove does not move my character. I changed it to controller.Move, and everything acts normally. I guess it was fighting gravity or some collisions, even though I zeroed out gravity and have my character on a separate Z-plane from anything he could collide with at the moment.

Note that this was using the base AIPath script with no modifications. I just rotated the graph -90 degrees on X and everything was fine!