-
-
Save API-Beast/634e78f5d408f3387b83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obj->Speed += obj->Acceleration * dt; | |
obj->Speed -= obj->Speed * (AirDrag * obj->Drag * dt) * obj->Speed.getLength(); | |
// Add gravity | |
for(GravitySource& src : GravitySources) | |
src.influence(obj, dt); | |
obj->Rotation += obj->RotationSpeed * dt; | |
Angle targetRotation = obj->Speed.getAngle(); | |
int sign = 1; | |
if(targetRotation < obj->Rotation) | |
sign = -1; | |
if((targetRotation - obj->Rotation) > 0.05f) | |
obj->Rotation += sign * (1 - obj->Speed.normalized().dot(obj->Rotation.toDirection())) * obj->Flow * obj->Speed.getLength() / 100 * dt; | |
obj->RotationSpeed -= (AirDrag * obj->Drag * dt) * obj->RotationSpeed; | |
obj->Position += obj->Speed * dt; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment