Get the speed the player is going
*/
bool is_climbing = lplayer->is_climbing;
+
+ /*
+ Check if the player is frozen (don't apply physics)
+ */
+ bool is_frozen = lplayer->is_frozen;
f32 player_speed = 0.001; // just some small value
player_speed = lplayer->getSpeed().getLength();
v3f lplayerpos = lplayer->getPosition();
// Apply physics
- if(free_move == false && is_climbing == false)
+ if(free_move == false && is_climbing == false && is_frozen == false)
{
// Gravity
v3f speed = lplayer->getSpeed();
/*
Calculate new position
*/
- position += m_speed * dtime;
+ if(is_frozen) {
+ // Still move very slowly so as not to feel all completely stuck
+ position += m_speed * dtime * 0.001;
+ }
+ else {
+ position += m_speed * dtime;
+ }
+
+ /*
+ If the player enters an unloaded chunk this is set to true.
+ */
+ is_frozen = false;
// Skip collision detection if a special movement mode is used
bool free_move = g_settings.getBool("free_move");
}
catch(InvalidPositionException &e)
{
- // Doing nothing here will block the player from
- // walking over map borders
+ if(!is_frozen) {
+ // freeze when entering unloaded areas
+ is_frozen = true;
+ }
+ continue;
}
core::aabbox3d<f32> nodebox = getNodeBox(v3s16(x,y,z), BS);