Moving Platforms

hi everyone

i have tried to make a moving platform using pathfinding automatism but have come across the following problem; i can get the platform to go down but i cant get it to come back up, here is what im doing and i have tried various ways but cant seem to get it to work, this is how i think code should look and can any1 tell me where im going wrong.

Event
no condition with action move VerticalPlatform to 1000,800 (This works)
Sub Event
condition is VerticalPlatform reached its destination with action move VerticalPlatform 1000,600.

if someone is kind enough to explain what im doing wrong it would be much appreciated

other things tried are;

Cheers

First, I don’t understand how you are using Pathfinding automatism to automatize a moving patform. Pathfinding is an automatism that finds a route from one point to another evading obstacles and it uses A* algorithm to do it (very used in top-down perspective games, for example, Age of Empires, where you click a unit and then click the place where you want it to go). It’s not neccesary to use pathfinding automatism to move a platform; you can do it trough the route automatism, but there are even more pratical ways to automatize a simple moving platform.

About your implementation: you are telling the game to ALWAYS move the platform to {1000,800}. And as a subevent, to move the platform to {1000,600} if the position of the platform is {1000,800}. In other words: when the platform reach {1000,800} for the first time, it will enter the conditionated subevent and move the platform some pixels towards {1000,600} (going up). BUT, in the next cycle, it anyways will move the platform back to {1000,800} again, because that’s what your events say (because it’s not conditionated). So once the platform is a few pixels near the {1000,600} coordinates, it will enter an eternal loop of moving some pixels up and down and that’s why I’m almost sure you can see a “tremble” effect in the platform when it get stuck.

But how to do it? Well, there are a few ways.

As I said before you can do it with the route automatism (NOT the pathfinfing automatism) but I recommend to reserve it for more complex paths.

The basic tutorial (it shows you how to ensemble a basic platformer) have an example of basic platform movement (the platform changes it’s direction when it touches invisible objects located at the sides of the route). So you can take a look on it.

My personnal recomendation is to use an object variable (let’s call it ‘direction’). This variable will tell us when the platform must go in one direction and when it have to travel in the other direction. For example: let’s start with ‘direction’ being 1, and that will mean going down; so if ‘direction’=1 then the platform object is moving towards a position below and always checking (as a subevent) if the platform already reach o surpass that position; in that case, ‘direction’ will become 0 and when ‘direction’=0 the same stuff will happen but moving the platform up. That’s how you set the cycle, 0 and 1, up and down.

Is better ilustrated with an example:

simple_moving_platform.zip (31.1 KB)

Hope it helps! :wink:

That is perfect thankyou, i was using pathfinding as that was the only way i could figure out how to move something without it being player controlled but that explanation answered everything :wink: