diff --git a/src/object/player.cpp b/src/object/player.cpp index 55e82530ed0..d90b646541b 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -2445,7 +2445,7 @@ Player::on_flip(float height) { Vector pos = get_pos(); pos.y = height - pos.y - get_bbox().get_height(); - set_pos(pos); + set_pos_reset(pos); } void @@ -2558,6 +2558,17 @@ Player::set_pos(const Vector& vector) { MovingObject::set_pos(vector); + // Make sure objects following Tux move directly with him + position_grabbed_object(true); + for (Key* key : m_collected_keys) + key->update_pos(); +} + +void +Player::set_pos_reset(const Vector& vector) +{ + m_col.set_pos(vector); + // Reset size to get correct hitbox if Tux was eg. ducked before moving if (is_big()) m_col.set_size(TUX_WIDTH, BIG_TUX_HEIGHT); @@ -3068,7 +3079,7 @@ Player::multiplayer_respawn() set_group(COLGROUP_MOVING); m_physic.reset(); - set_pos(target->get_pos()); + set_pos_reset(target->get_pos()); m_target.reset(); }