SOLVED The Moving Platforms Trouble.


I finally made a 'one-way block' right. Here is the collision code without the 'movement':

var plat = collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom +abs(vspd) +1,argument0,1,0);
if (vspd >= 0) and (plat != noone) and !collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom,plat,1,0)
      while !collision_rectangle(bbox_left,bbox_bottom+1,bbox_right,bbox_bottom+1,plat,1,0) {y += 1;}
      vspd = 0;

It works very well, but I'm trying to make a moving platform collision and ... the 'movement problem' is basically solved. The logic I used in sequence is this:

1. Platform calculates its own spd (Begin step);
2. Player checks the collision with the platform (Step);
3. Player moves with your own spd (Step);
4. Player moves based on the platform spd (Step);
5. Platform moves with its own spd (End step).

Idk if it's important but i made a fake 'x' and 'y' for platform to make it move only in integer numbers.

The 'end step' collision ('xp' and 'yp' is the next coordinate of platform):

if collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom +abs(vspd)+1,argument0,1,0)
      var ins = collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom +abs(vspd) +1,argument0,1,0);

      if (vspd >= 0) and !collision_rectangle(bbox_left,bbox_bottom,bbox_right,bbox_bottom,ins,1,0)
            var ins_vspd =  ceil(ins.yp) - ins.y;
            var ins_hspd =  ceil(ins.xp) - ins.x;
            if place_freeground(x,y +ins_vspd +vspd) {y += ins_vspd;}
            if place_freeground(x +ins_hspd +hspd,y) {x += ins_hspd;}
The real problem is in the collision check, because... look!

The collision considers only the 'vspd' of the player and sometimes he crosses the platform as in this example:


The player's vspd is '+1' and platform's vspd is '-2' the player check 'abs (vspd) +1' and cannot verify right. I need to get the platform's vspd too for this, but i don't know how. This is something that i wanted for a long time, to check collision between two objects and considerate both of them speeds.