Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void lookAt(float x, float y) {
- final float tolerance = (float) Math.PI / 9;
- final float angle = (float) (Math.atan2(y, x) - Math.PI / 2);
- if (physics.getRotation() <= angle + tolerance && physics.getRotation() >= angle - tolerance) {
- physics.setRotation(angle);
- } else if (physics.getRotation() > angle + tolerance) {
- physics.setAngularVelocity(-15);
- } else if (physics.getRotation() < angle - tolerance) {
- physics.setAngularVelocity(15);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement