Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: FortressCaulfield on Thu 30/05/2024 12:20:24

Title: Better movement options
Post by: FortressCaulfield on Thu 30/05/2024 12:20:24
Getting a little frustrated with move. Is there some way I'm missing to get something to move in an arc, or to accelerate or decelerate? What if I want something moving slower than 1? In some cases I can fake what I want by doing it in the animation but that seems highly inefficient.

Seems like what I'd have to do is put a special handler into repeat-always that does the math. Is there some other work-around I'm not seeing?
Title: Re: Better movement options
Post by: Crimson Wizard on Thu 30/05/2024 12:53:00
No, I'm afraid that for the most of these things (acceleration, moving not in straight line) you'll have to script your own movement.
I may also recommend checking out Tween module which adds interpolation functions for many game properties, and may have something suitable (but it depends on a use case):
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/tween-2-3-0-with-ags-3-6-0-support!/

In regards to have a move speeds less than 1 pixel per game update, that is possible by passing negative speed value, where -N would mean 1 pixel per N updates.

Title: Re: Better movement options
Post by: FortressCaulfield on Thu 30/05/2024 14:47:25
Hmmm. What would such a function even look like? Do you just have to stack move commands, or do a while loop and manually set x and y? It doesn't appear that speed or destination coordinates are accessible values, at least not for objects
Title: Re: Better movement options
Post by: Crimson Wizard on Thu 30/05/2024 15:11:56
I meant manually setting x and y position.

If it has to be a blocking move, then this may be done in a loop. If non-blocking, then in repeatedly_execute function (or repeatedly_execute_always, if necessary).

But I don't know your use case. Above solution implies you are in full control of movement path.

If, on another hand, you need to use AGS pathfinding (object moving along walkable areas), then the situation becomes more complicated, because AGS does not expose pathfinding results to script. In such case the only workaround that I know is a "ghost" object/character: order an invisible object to move, and then move your actual object relatively to the "ghost", with custom adjustments. This is in very simple terms, but depending on a practical case this may require remembering the "ghost"'s steps, for example, or more.