Skip to content

Commit

Permalink
Fix camera "jumping" when attached and the parent goes too fast
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeg9 authored and PilzAdam committed Apr 3, 2013
1 parent f85c116 commit c1bf6f9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/camera.cpp
Expand Up @@ -218,6 +218,8 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize,
// Smooth the movement when walking up stairs
v3f old_player_position = m_playernode->getPosition();
v3f player_position = player->getPosition();
if (player->isAttached && player->parent)
player_position = player->parent->getPosition();
//if(player->touching_ground && player_position.Y > old_player_position.Y)
if(player->touching_ground &&
player_position.Y > old_player_position.Y)
Expand Down
1 change: 1 addition & 0 deletions src/content_cao.cpp
Expand Up @@ -1129,6 +1129,7 @@ class GenericCAO : public ClientActiveObject
{
LocalPlayer *player = m_env->getLocalPlayer();
player->overridePosition = getParent()->getPosition();
m_env->getLocalPlayer()->parent = getParent();
}
}
else
Expand Down
1 change: 1 addition & 0 deletions src/localplayer.cpp
Expand Up @@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,

LocalPlayer::LocalPlayer(IGameDef *gamedef):
Player(gamedef),
parent(0),
isAttached(false),
overridePosition(v3f(0,0,0)),
last_position(v3f(0,0,0)),
Expand Down
4 changes: 4 additions & 0 deletions src/localplayer.h
Expand Up @@ -25,6 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,

class ClientEnvironment;

class ClientActiveObject;

class LocalPlayer : public Player
{
public:
Expand All @@ -35,6 +37,8 @@ class LocalPlayer : public Player
{
return true;
}

ClientActiveObject *parent;

bool isAttached;

Expand Down

0 comments on commit c1bf6f9

Please sign in to comment.