GMS 2.3+ How can I adjust the speed of an object that is already in motion?

XD005

Member
Hello everyone,

I've been ripping my hair out over this for a while.
The solution is probably simple and I'm just overlooking things...

I am trying to create a note speed script that will create the objects in such a manner that they arrive to the target on-time while allowing their speed to be adjusted mid-travel.
If possible, I need them to respect each other's size. If the scrolling speed is too low, notes stack on top of each other. If this isn't possible, I can live without it.
This is the current code....


Object creation code
GML:
var note_travel_time_ms = (point_distance(spawn_x,spawn_y,zone_x,zone_y) / global.gem_speed) * (1000/room_speed);
//Note_millisecond is the time the note should be perfectly lined up with the target
var duration = (note_travel_time_ms/global.gem_speed);
if (global.millisecond >= (note_millisecond - duration)){
        index_id = instance_create_layer(spawn_x,spawn_y,"Gameplay_Foreground",obj_node);
    }
And then the node objects
GML:
//Timing prog is the percentage until the note should have been on the target perfectly  
var timing_prog = (global.millisecond - timecapture) / (node_time - timecapture);
timing_progress += (delta_time/1000000);

    x = lerp (startx, obj_discs_controller.zone1_x, timing_progress*global.gem_speed);
    y = lerp (starty, obj_discs_controller.zone1_y, timing_progress*global.gem_speed);
    //Old method using progress of time instead of elapsed time since creation
    //x = lerp(startx, obj_discs_controller.zone1_x, timing_prog);
    //y = lerp(starty, obj_discs_controller.zone1_y, timing_prog);
Any help with this is appreciated
 

Nidoking

Member
It sounds like you need to work out a formula for where you want the notes to be, rather than a linear calculation from start to finish. That's going to depend on more factors than it's likely possible to list here.
 
Top