Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/badguy/walking_badguy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,21 @@ WalkingBadguy::collision_solid(const CollisionHit& hit)
if (m_physic.get_velocity_y() > 0) m_physic.set_velocity_y(0);
}

if ( hit.slope_normal.x == 0.0f &&
((hit.left && m_dir == Direction::LEFT) ||
(hit.right && m_dir == Direction::RIGHT)) ) {
if ((hit.left && m_dir == Direction::LEFT) ||
(hit.right && m_dir == Direction::RIGHT)) {

// Enemies get stuck in some tiles #3239 FIX
// When a bad guy is about to step onto a slope, have it manually step onto it
if (std::abs(hit.slope_normal.x) > 0.0f && std::abs(hit.slope_normal.x) < 0.7f) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you maybe move the std::abs(hit.slope_normal.x) into a variable? That way, this if statement would fit into a line

Vector movement = m_col.get_movement();
movement.y -= 5;
m_col.set_movement(movement);
// setting the movement of the CollisionObject
} else {
// If it's anything but a sloped surface, turn around like normal
turn_around();
}
}

}

HitResponse
Expand Down
Loading