Rotating platform issues

V

Vito_Curse

Guest
Okay. So I'm making a game where gears rotate and you can stay on top of them, but of course, they make you move towards the angle they are moving. It works EXACTLY like the ones in the Castlevania series.

Example:

The issue appears when I try to make them not drag the player around when there is a block in the way. Imagine if in the video I sent there was a big solid block right above the center of the gear, the player should keep being pushed towards it, but not go through said block.

Right now I'm using this code for the gears, but I think the problem may be in the fact that i'm using hsp and vsp for player movement while the gear interacts directly with the players x and y:

Code:
if(place_meeting(x,y-2,obj_player)) && obj_player.y<y
{
    with(instance_place(x,y-1,obj_player))
   {
        var _p1x = x;
        var _p1y = y;
        var l=point_distance(other.x,other.y,_p1x,_p1y);
        var d = point_direction(other.x,other.y,_p1x,_p1y)+(-1*obj_gear.image_xscale);
      

        x = other.x + lengthdir_x(l,d)
        y = other.y + lengthdir_y(l,d)
      
        while(place_meeting(x, y, other))
       {
            x += lengthdir_x(1,d)
            y += lengthdir_y(1,d)
        }

      
   }
}
 
V

Vito_Curse

Guest
As I said, I think the problem is in using x and y instead of working with hsp and vsp, but I have no idea how to convert that information into those variables for speed instead of coordinates. So it just doesn't work when I add any code for block collision, it just goes through blocks.
 

obscene

Member
Seems you could just check for a collision here....

var xx, yy;
xx = other.x + lengthdir_x(l,d)
yy = other.y + lengthdir_y(l,d)
if !place_meeting(xx,yy,par_block) { x=xx; y=yy; }
 
M

maru_th_undrtkr

Guest
Heres a wild idea but it should work. Since its a rotating circle. Instead of influencing the player by controlling his x y position. When he is planted on the object his movent speed can have a forced applied to it in thr direction the wheel is spinning. If you can handle slopes and use velocity, it should work. There's tutorials for slopes by heartbeast and... I don't remember. But its prob easier than platforms. Just check ground for that type of object
 
Top