Moving Platforms

Moving platforms and elevator support is something that has been lacking a bit in the A* Pathfinding Project up until now. So I started thinking about it during the weekend, and figured that it shouldn’t be too hard to implement, so I did that 😀
What I ended up with was an implementation using one-way links. That is, if you have an elevator which only goes up, I would create one node at the bottom of it, and one at the top, and then add a link between them which only goes in one direction: from bottom to top.
I created a new graph type named LinkGraph, the idea is that it should always be present as the first graph in the scene. And a few scripts which enables you to create new nodes and connections using gameObjects which you place in the scene. It works similar to a list graph, but the nodes are not connected automatically, you have scripts which specify a connection from one point to another point, nodes will be created at both endpoints and automatically (currently not so sophisticated, might add more features there) connects them to nearby nodes in other graphs.
Further, I have an elevator/moving platform script which checks a trigger, if the AI stands on the platform for a specified length of time, it will lock the AI so it will not be able to move during transport to the target location, it will then move, and release the ai to move freely when it has reached it’s target location.
This simple technique works unexpectedly well in my tests.

Ways to improve it would probably be to tag the elevator nodes with certain tags which tell the AI to stop at the first one and then wait for it to move to the next instead of trying to walk towards it. That would free the elevator script from having to lock the AI from moving. It would be better in that the current system can fail if the AI walks too fast.

Here’s a video of what it looks like at the moment. Oh, and also, I have written a new AI script which has much better movement behavior than the previous AIFollow script, the one in the video is the new script, a bit modified to be able to animate the legs of the robot properly and to create a particle effect when it reaches the end of the path.


  1. Sali says:

    hi Aron … how are you … thank you a lot for the great work you made 🙂 …

    I’m using GridGraph and if the Target is in the Second floor I Stuck under the target and can’t move using Stairs >>> Mention that I’m using Guider person that guide me to the target and AiFollow is Attached to him >>> how to make him goes up and down using stairs >>> and why sometimes he Stuck out side in front of some wall even that wall is an Obstcale

        • Aron Granberg says:

          Hey, don’t be so harsh, he’s right actually.
          I see I didn’t actually write it in the text, which was a bit bad. But anyway, this is for the next release (3.1) of the system. I still have many changes and rewrites to do.

          • Sali says:

            ok , I’m sorry … but really I love your work … and I hope someday to be like you 🙂
            for now I’m developing a small Game >>> and it has 3d buildings >>> you can go inside the building >>> and there is rooms and offices >>> anyway >>> the system should help you at first to find the shortest Path to find any room in the building >>> using AI PathFinding and the GridGraph >>> still the Problem is in the stairs can’t go up or down if the target in another floor it stuck under/above the target location 🙁 the system uses Guider person ( AI man ) that help you to find your way <<<how to fix this problem? please help me

Comments are closed.