falador1 2 Share Posted March 25, 2021 Hey, is it possible to have a getter function for yaw for an entity. Trying to randomize Camera.rotateto(Entity) is difficult. There might already be a function i'm not seeing? EDIT: Looking back I put pitch in the title when I should've put Yaw. If anyone comes across this heres the helper function public int getYaw(Entity ent) { //vector going to game object int[] gameVector = {ent.getX() - getLocalPlayer().getX(), ent.getY() - getLocalPlayer().getY()}; //default 0 yaw vector <0, 1> int[] playerVector = {0, 1}; //radian of angle double rad = Math.acos(gameVector[1]/(Math.sqrt(Math.pow(gameVector[0], 2) + Math.pow(gameVector[1], 2)))); //convert to yaw int yaw = (int) (2048 -(rad * (1024/Math.PI))); log("Yaw is: " + yaw); return yaw; } Link to comment Share on other sites More sharing options...
Pandemic 2494 Share Posted March 25, 2021 I'm not sure what you're looking for, an entity's pitch and yaw? Or the pitch and yaw the game camera should be at? In either case we don't have a method like that, but you can do some simple math to write your own helper method if you really want to. Link to comment Share on other sites More sharing options...
falador1 2 Author Share Posted March 28, 2021 The pitch and yaw the camera should be at. I was wanting to create a camera movement algorithm that could randomize my camera movements similar to the setMouseMovement function. There doesn't seem to be a an open source method for it, so trying to make my spaghetti code work. xD I could get the tile of my character compare to the entity tile and adjust camera accordingly. Just wondering if you guys already wrote that logic in rotatetoentity. Thanks for the response more coding for me 😢 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.