Jump to content

CameraEntityEvent


Recommended Posts

Posted (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 by iJodix
Posted (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 by FrostBug
  • Like 3
Posted (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! QwPha8E.png QwPha8E.png QwPha8E.png QwPha8E.png QwPha8E.png QwPha8E.png

Edited by iJodix
Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...