• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

 [FEATURE] Pathing Improvements Majorly Needed

tagwolf

Member
I was instructed to open this thread by a GMS2 staffer.

Problem:

Pathing functions are currently extremely limited in their functionality. In other cases are broken and have missing features. Path points are pretty much pointless in GML.

Suggested Fixes:

* Allow moving an object towards a point and functionality to check how far away an object along a path is from a path point.
- E.g. All needed functions to create a working elevator should exist without having to write your own pathing system.

* Introduce a more useful function than path_position to move an object along a path. Currently path_position only allows moving to a position between 0.0 and 1.0 (0 - 100%) of the total path length with no way to determine point position, distance, etc.

E.g.

--- = path
* = point

*--------*------------*-------*

Functions should exist to do the following:

* Determine distance along path to a point
* Move object along path towards a point
* Move an object to a point on the path
* Set speed between 2 points
* Update points on a path without disrupting the object on the path
* Ability to move paths around the room in real time or ATTACH paths to other moving objects, etc.
* etc.

Again, just basic functionality to create a multiple floor elevator for instance without making your own pathing system.


INCLUDING MY ORIGINAL REDDIT/BUG POST BELOW TO GIVE CLARIFICATION OF THE ORIGINAL PROBLEM I HAD WITH PATHING:


I've come to the conclusion that the pathing in gamemaker is extremely limited in it's flexability and is missing several of the functions required to make even a basic elevator with 3 floors.

To give some background, I have created an elevator object in a building. It's set to a path which has 3 points (one per floor of the building).

To start, I want to just for now, make the elevator stop on each floor. I've tried several different methods to work around this:

1) Check path_get_point_y in a step event, and when the object has reached or past that point, reduce the path speed to 0. (X and Y positioning do NOT appear to work once you tell an object to start following a path... so that limits things a bit as I can't just do something like: y = path_get_point_y(path1, 2);

2) Determine the destination to stop at once following a path and set that point speed to 0. Effectively stopping the object there.

Tried #1. No bueno. The object consistently moves 1-2 pixels past the point. Trying the point speed method next I guess. Worst case I may need to write my own pathing system.

Tried #2... which looks like it actually decelerrates before reaching the point at some undetermined and unknown rate/amount. Sadness :( However this must be set in the path manually before starting to follow.

When I try to change a path, it seems to throw my elevator to the end of the path whenever changing a point's speed. This happens even if I change it before starting on the path.

Here's some example step code from the elevator:

switch (keyboard_key) {
case vk_numpad0: floor_pressed = 0; break;
case vk_numpad1: floor_pressed = 1; break;
case vk_numpad2: floor_pressed = 2; break;
}

floor_pressed_x = path_get_point_x(path_lift, floor_pressed);
floor_pressed_y = path_get_point_y(path_lift, floor_pressed);

path_change_point(path_lift, floor_pressed, floor_pressed_x, floor_pressed_y, 0);

if (floor_pressed > 0) {
path_start(path_lift, 1, path_action_stop, 1);
} else {
path_end();
}

I was hoping for some more functionality regarding path points build into gamemaker. What is really needed is a way to move an object to a point on the path.

It seems like the extent of it is for making moving platforms go back and forth in platformer games, etc.

It's missing several functions needed to make it worth using for anything beyond basic use. I'm confused at the inclusion of path points if you cannot move an object to a point on the path and can only move the object to a percentage of the total path based on 0 - 1.

All workarounds I've tried above have failed and bugged out, causing the object to jump to the end of the path and stop.

Hopefully this is just an error in my code or logic and someone has a good solution.

But I'm worried that I will need to write my own pathing system to control an elevator.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
While GMS definitely could have a couple more functions for paths, I think using paths for a regular vertical elevator is a bit of an excess. I mean, you could have a script like
Code:
/// approach(value, target, step)
var a = argument0;
var b = argument1;
if (a < b) {
   a += argument2;
   if (a < b) return a; else return b;
} else {
   a -= argument2;
   if (a > b) return a; else return b;
}
And do
Code:
last_y = y;
y = approach(y, target_y, vel_y);
shift_y = y - last_y;
where
  • target_y: destination floor' Y
  • vel_y: elevator' movement speed (in pixels per frame)
  • shift_y: resulting change of coordinates (for moving any objects inside elevator, if you have those)
and then you'd just change target_y to order elevator to go to a different floor.
 
Top