Created
January 7, 2016 18:42
-
-
Save nanonull/0e8aa16159fa8fc03431 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
protected void process(Entity e) { | |
// TODO if baseBody was destroyed then disable rotation | |
StationaryGunMotorComponent gunComponent = components.get(e); | |
Box2dBodyComponent bodyComponent = Box2dBodySystem.components.get(e); | |
float desiredWorldAngle = gunComponent.getDesiredWorldAngleRads(); | |
float currWorldAngle = MathUtilsExt.absRadians(bodyComponent.body.getAngle()); | |
float angleDelta = MathUtilsExt.diffAbsoluteRadians(currWorldAngle, desiredWorldAngle); | |
if (MathUtilsExt.areDecimalsEqual(angleDelta, 0)) { | |
return; | |
} | |
// act motor | |
Box2dMotorJointActionComp motorJointActionComp = Box2dMotorJointActionSystem.components.create(e); | |
motorJointActionComp.force = (angleDelta / Math.abs(angleDelta)) * FORCE_DELTA; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment