Jump to content

CameraEntityEvent


iJodix

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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