SC2Mapster.com Wiki

SC2 API / Functions / CameraGetTarget

UnitGetPosition

point CameraGetTarget(int player);

Position watched by the player.

Parameters

int player

Player that is watching. Also works for AI.

Return value

point - Position watched by the player. To get it you draw a ray from the center of the screen (intersection of diagonals) and see where it hits the ground.

Examples

Example: IsPlayerWatching
// Tell if the player camera can see the unit
bool IsPlayerWatching(int player, unit u) {
  point cameraPos = CameraGetTarget(player);
  point unitPos = UnitGetPosition(u);

  return DistanceBetweenPoints(cameraPos, unitPos) < 20;
}
  • cameragettarget.jpg

You must login to post a comment. Don't have an account? Register to get one!

Facts

Date created
Mar 24, 2010
Last updated
Mar 24, 2010

Author