SFML Camera

So, I'm trying to make a camera move with the character in the game, and it's in a void that updates with a clock variable elapsedTime. In the same function, I have the character moving with regards to elapsedTime, and it runs well. But, when I put it in the camera.move, it essentially kills the camera. I was wondering if there were any reason why it did not work with the code down below, and if there was a way I could get it to work. Thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();

camera.reset(sf::FloatRect(0, 0, desktop.width, desktop.height));
camera.setCenter(desktop.width / 2, desktop.height / 2);

if (VisibleGameObject::GetWidth() <= ((desktop.width / 2) - 164)
    || VisibleGameObject::GetWidth() >= ((desktop.width / 2) + 164)
    || VisibleGameObject::GetHeight() <= ((desktop.height / 2) + 164)
    || VisibleGameObject::GetHeight() >= ((desktop.height / 2) - 164)
     )
{
    camera.move(_velocityX * elapsedTime, _velocityY * elapsedTime);
}
	
Game::_mainWindow.setView(camera);
Topic archived. No new replies allowed.