You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to make a collision between a player and a wall, but the collision only gets detected from the left side of the wall and not the right, I've checked the bounding box and it encapsulates the whole box so I am not sure why this is happening.
FXGL.getPhysicsWorld().addCollisionHandler(new CollisionHandler(EntityType.PLAYER, EntityType.WALL) { @OverRide
protected void onCollisionBegin(Entity player, Entity wall) {
if (wall.getX() >= 800) {
player.setPosition(wall.getX() - 235, 405);
}
else {
player.setPosition(wall.getX() + 10, 405);
}
}
});
the if statement is because I have 2 walls, one on the left side of the map and one the right. This is probably just a simple issue but I can't figure out why it is happening so help would be much appreciated.
EDIT: it somehow fixed itself... we truly live in a society.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to make a collision between a player and a wall, but the collision only gets detected from the left side of the wall and not the right, I've checked the bounding box and it encapsulates the whole box so I am not sure why this is happening.
FXGL.getPhysicsWorld().addCollisionHandler(new CollisionHandler(EntityType.PLAYER, EntityType.WALL) {
@OverRide
protected void onCollisionBegin(Entity player, Entity wall) {
if (wall.getX() >= 800) {
player.setPosition(wall.getX() - 235, 405);
}
else {
player.setPosition(wall.getX() + 10, 405);
}
}
});
the if statement is because I have 2 walls, one on the left side of the map and one the right. This is probably just a simple issue but I can't figure out why it is happening so help would be much appreciated.
EDIT: it somehow fixed itself... we truly live in a society.
Beta Was this translation helpful? Give feedback.
All reactions