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:
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)
}
}
}