iJodix Posted August 3, 2015 Posted August 3, 2015 (edited) Ok so, any ideas why this doesn't want to move the camera ? NPC npc = getNpcs().closest(npcFitler); CameraEntityEvent ce = new CameraEntityEvent(npc); execute(ce); Edited August 3, 2015 by iJodix
itzDot Posted August 3, 2015 Posted August 3, 2015 Ok so, any ideas why this doesn't want to move the camera ? CameraEntityEvent ce = newCameraEntityEvent(npc); NPC npc = getNpcs().closest(npcFitler); maybe you should put a space between "newCameraEntityEvent" i could be wrong dou
iJodix Posted August 3, 2015 Author Posted August 3, 2015 (edited) maybe you should put a space between "newCameraEntityEvent" i could be wrong dou Oh sorry, i re-wrote the code to the thread so made a typo. Edited August 3, 2015 by iJodix
Precise Posted August 3, 2015 Posted August 3, 2015 Oh sorry, i re-wrote the code to the thread so made a typo. i always had trouble with #execute(Event e); my solution was: this.getBot().getEventExecutor().execute(ce); Hope this helps! Precise.
iJodix Posted August 3, 2015 Author Posted August 3, 2015 (edited) i always had trouble with #execute(Event e); my solution was: this.getBot().getEventExecutor().execute(ce); Hope this helps! Precise. Ok, it .. kinda moves the camera ? Like few pixels .. I don't have any issues with executing the MoveMouseEvent Edited August 3, 2015 by iJodix
Zee Best Posted August 3, 2015 Posted August 3, 2015 The camera class seems to be broken at the moment, manually setting the Yaw or using toEntity/toPosition doesn't work 99% of the time.
FrostBug Posted August 3, 2015 Posted August 3, 2015 (edited) try this /* * Rotate the camera to an entity; Based on angle calculations */ public void cameraToEntity(Entity e) { cameraToPosition(e.getPosition()); } /* * Rotate the camera to a Position; Based on angle calculations */ public void cameraToPosition(Position p) { Position pos = myPosition(); int angle = 90 + (int) Math.toDegrees(Math.atan2(-(p.getY() - pos.getY()), p.getX() - pos.getX())); int yaw = angle < 0 ? Math.abs(angle) : 360 - angle; CameraYawEvent evt = new CameraYawEvent(yaw); execute(evt.setBlocking()); } EDIT: or just try to set whatever camera event you're using to be blocking (Event#setBlocking) before executing it. Edited August 3, 2015 by FrostBug 3
iJodix Posted August 3, 2015 Author Posted August 3, 2015 (edited) try this /* * Rotate the camera to an entity; Based on angle calculations */ public void cameraToEntity(Entity e) { cameraToPosition(e.getPosition()); } /* * Rotate the camera to a Position; Based on angle calculations */ public void cameraToPosition(Position p) { Position pos = myPosition(); int angle = 90 + (int) Math.toDegrees(Math.atan2(-(p.getY() - pos.getY()), p.getX() - pos.getX())); int yaw = angle < 0 ? Math.abs(angle) : 360 - angle; CameraYawEvent evt = new CameraYawEvent(yaw); execute(evt.setBlocking()); } EDIT: or just try to set whatever camera event you're using to be blocking (Event#setBlocking) before executing it. Thank you! Edited August 3, 2015 by iJodix
Bobrocket Posted August 3, 2015 Posted August 3, 2015 try this /* * Rotate the camera to an entity; Based on angle calculations */ public void cameraToEntity(Entity e) { cameraToPosition(e.getPosition()); } /* * Rotate the camera to a Position; Based on angle calculations */ public void cameraToPosition(Position p) { Position pos = myPosition(); int angle = 90 + (int) Math.toDegrees(Math.atan2(-(p.getY() - pos.getY()), p.getX() - pos.getX())); int yaw = angle < 0 ? Math.abs(angle) : 360 - angle; CameraYawEvent evt = new CameraYawEvent(yaw); execute(evt.setBlocking()); } EDIT: or just try to set whatever camera event you're using to be blocking (Event#setBlocking) before executing it. Been a long time since I saw the atan2 function lol.