falador1 2 Share Posted March 25, 2021 (edited) 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; } Edited April 2, 2021 by falador1 Nick U 1 Link to comment Share on other sites More sharing options...
Pandemic 2426 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. falador1 1 Link to comment Share on other sites More sharing options...
falador1 2 Author Share Posted March 28, 2021 (edited) 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 😢 Edited March 28, 2021 by falador1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now