Made it possible again to move the camera upwards.
This commit is contained in:
parent
d02a7fa02f
commit
6ee8af58e3
@ -48,9 +48,10 @@ void Physics::takeUpdateStep(float timeDiff)
|
|||||||
position *= 5;
|
position *= 5;
|
||||||
position += playerBall->getCenterOfMassPosition(); //is the position 5 units away from the player in the direction of the camera
|
position += playerBall->getCenterOfMassPosition(); //is the position 5 units away from the player in the direction of the camera
|
||||||
|
|
||||||
|
//prevent the camera from being dragged along on the ground
|
||||||
|
if (position.getY() < playerBall->getCenterOfMassPosition().getY() + 1)
|
||||||
position.setY(playerBall->getCenterOfMassPosition().getY() + 1);
|
position.setY(playerBall->getCenterOfMassPosition().getY() + 1);
|
||||||
|
|
||||||
|
|
||||||
btVector3 dir = cameraBody->getCenterOfMassPosition() - position;
|
btVector3 dir = cameraBody->getCenterOfMassPosition() - position;
|
||||||
float str = cameraBody->getInvMass()*50 * dir.length();
|
float str = cameraBody->getInvMass()*50 * dir.length();
|
||||||
cameraBody->applyCentralForce(-dir*str);//scale the force by camera mass
|
cameraBody->applyCentralForce(-dir*str);//scale the force by camera mass
|
||||||
@ -355,7 +356,7 @@ glm::vec3 Physics::getCameraPosition()
|
|||||||
return save;
|
return save;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 Physics::getCameraToPlayer()//returns a glm::vec3 the goes from the player to the camera
|
glm::vec3 Physics::getCameraToPlayer()//returns a glm::vec3 the goes from the camera to the player
|
||||||
{
|
{
|
||||||
btVector3 origin = playerBall->getCenterOfMassPosition() - cameraBody->getCenterOfMassPosition();
|
btVector3 origin = playerBall->getCenterOfMassPosition() - cameraBody->getCenterOfMassPosition();
|
||||||
glm::vec3 save(origin.getX(),origin.getY(),origin.getZ());
|
glm::vec3 save(origin.getX(),origin.getY(),origin.getZ());
|
||||||
|
Loading…
Reference in New Issue
Block a user