• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] IsUnitVisible

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
Hello, I want to display a floating text if a certain unit is visible, with other words if the unit is within camera range.

My only idea was to create a temp region and calculate the size of it depending on the current camera settings. But that seems both buggy and advanced, any other ideas?

edit1: a second idea would be to calculate the distance between the unit and the center of the camera, however this wont work since my screen is not a square.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
not everything that is in the camera's field of view is on the screen, consider fog of war.

If this is single player you shouldnt have much problem, if this is multiplayer, it may be a bit of a problem to avoid desyncs
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Just display a floating text if that unit is not in fog of war for player.

If his camera is not looking there he won't see text anyway???
 
The text is following the screen atm, but that's rather pointless if you can't see the unit that the text is "attached" to.

I think checking if the unit is visible for player X isn't good enough in my case, sorry.

You need a combination of IsUnitVisible for the local player and your suggestion on post #1, which is merely this. Just add an extra condition to see whether the unit is in the defined region.

The former will allow you to see if the unit, given that it is within the local player's camera target region, is still visible to the player (e.g. has been hidden with the action Unit - Hide unit or is invisible through spells).
 
Status
Not open for further replies.
Top