Hi,
I'm having a lot of difficulty getting a particular collision detection to work properly, but only for HMTL5, and only when the player is colliding with the object from above.
The object is a block that can be pushed in four directions, as long as it's along a rail. The player in this code is called 'obj_jink', and the idea here is that in the case of a collision, it establishes whether the block can be pushed, the direction of push, and then controls the speed of both the player and the block:
This works absolutely as it should if I preview in the Windows version. In HTML5, however, pushing down on the block causes the player to move inside the block. A similar problem occurs if the player is pushing to the left or right, but only if the player is standing toward the top end of the block. Pushing upwards from the bottom, or to the left and right from the bottom, everything s fine.
In other words, it seems to be a really clear case of the collision boxes failing to register when the bottom of the player's box collides with the top of the block's box.
Can anyone confirm for me that this is a bug, or explain what I'm doing wrong?
I'm having a lot of difficulty getting a particular collision detection to work properly, but only for HMTL5, and only when the player is colliding with the object from above.
The object is a block that can be pushed in four directions, as long as it's along a rail. The player in this code is called 'obj_jink', and the idea here is that in the case of a collision, it establishes whether the block can be pushed, the direction of push, and then controls the speed of both the player and the block:
Code:
with obj_jink {
if place_meeting(x + hspeed, y + vspeed, other) {
//Establish direction of push
var udlr
var dir = point_direction(x, y, other.x, other.y);
if dir > 44 and dir <= 135 udlr = "up"
else if dir > 135 and dir <= 225 udlr = "left"
else if dir > 225 and dir <= 315 udlr = "down"
else udlr = "right"
//Separate condition for each direction
if other.moveleft = true and udlr = "left" {
hspeed = clamp(hspeed, -other.spd, 0);
other.x += hspeed;
}
else if other.moveright = true and udlr = "right" {
hspeed = clamp(hspeed, 0, other.spd);
other.x += hspeed;
}
else if other.moveup = true and udlr = "up" {
vspeed = clamp(vspeed, -other.spd, 0);
other.y += vspeed;
}
else if other.movedown = true and udlr = "down" {
vspeed = clamp(vspeed, 0, other.spd);
other.y += vspeed;
}
In other words, it seems to be a really clear case of the collision boxes failing to register when the bottom of the player's box collides with the top of the block's box.
Can anyone confirm for me that this is a bug, or explain what I'm doing wrong?