Skip to content

Commit 907ca4e

Browse files
author
vboxuser
committed
Fix WalkingBadguy getting stuck on curved tiles (#3239)
1 parent b02e260 commit 907ca4e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/badguy/walking_badguy.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,21 @@ WalkingBadguy::collision_solid(const CollisionHit& hit)
200200
if (m_physic.get_velocity_y() > 0) m_physic.set_velocity_y(0);
201201
}
202202

203-
if ( hit.slope_normal.x == 0.0f &&
204-
((hit.left && m_dir == Direction::LEFT) ||
205-
(hit.right && m_dir == Direction::RIGHT)) ) {
203+
if ((hit.left && m_dir == Direction::LEFT) ||
204+
(hit.right && m_dir == Direction::RIGHT)) {
205+
206+
// Enemies get stuck in some tiles #3239 FIX
207+
// When a bad guy is about to step onto a slope, have it manually step onto it
208+
if (std::abs(hit.slope_normal.x) > 0.0f && std::abs(hit.slope_normal.x) < 0.7f) {
209+
Vector movement = m_col.get_movement();
210+
movement.y -= 5;
211+
m_col.set_movement(movement);
212+
// setting the movement of the CollisionObject
213+
} else {
214+
// If it's anything but a sloped surface, turn around like normal
206215
turn_around();
216+
}
207217
}
208-
209218
}
210219

211220
HitResponse

0 commit comments

Comments
 (0)