How to filter the entities with the angle you need to rotate to the entities like in killaura? #240
Answered
by
Andy718811
Andy718811
asked this question in
Q&A
-
|
Here is the code I tried, but it didn't work as I wished. |
Beta Was this translation helpful? Give feedback.
Answered by
Andy718811
Mar 22, 2026
Replies: 1 comment 1 reply
-
|
Bro, I can't debug code for you. Just learn how to do it yourself. I added this for status overlay script: {
let entity_id = 2; // id of entity i get in advance
let x_player = player.getX();
let y_player = player.getY();
let z_player = player.getZ();
let x = game.entities.getX(entity_id);
let y = game.entities.getY(entity_id);
let z = game.entities.getZ(entity_id);
float dx = x - x_player;
float dz = z - z_player;
float yaw = player.getYRot();
yaw = ((yaw + 180) % 360 + 360) % 360 - 180;
float targetYaw = math.degrees.atan2(dz, dx) - 90; // i noticed calculated angle is 90 degrees bigger, so I subtract 90
float diff = targetYaw - yaw;
diff = ((diff % 360) + 360) % 360;
if (diff > 180) diff -= 360;
/*if (math.abs(diff) > 70) {
continue;
}*/
overlay.center();
overlay.middle();
overlay.add(diff.toStandardString(3));
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thak you, after some try, I found the reason it failed is because I should trun the angle to between 0 to 360 degree. After some modification, it worked!