• 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.

Camera script (z offset of unit)

Status
Not open for further replies.
Level 4
Joined
Feb 8, 2009
Messages
61
Hello hivers. i have a slight problem with a trigger.
i need the camera to folow a units X,Y and Z positions. X and Y was no problem but Z were not in the normal triggers.
i want something like this:
Set camera position Z To Z position of (my Unit variable [number of (triggering player)]) by offset 20
 
Last edited:
Level 11
Joined
Feb 22, 2006
Messages
752
Isn't there a trigger action that locks a camera on a unit?

And there is a jass function called GetLocationZ() that returns the z-value of the specified location. The only thing with this function is that near cliffs, it will return a set of z values as if the ground steadily sloped upward instead of being flat and then going straight up at the cliff (these are the z values that a flying unit uses to determine its absolute flying height...which is why you don't see flying units suddenly jerk upwards every time they crossed a cliff boundary), so you might get some weird behavior around cliffs.
 
Level 11
Joined
Jun 21, 2007
Messages
505
Wait, I have to warn you. To properly set the camera's height to unit's you need these:
First of all, you need a variable or type Real to store the value returned by GetLocationZ function in it.
A variable determining camera height offset. You set the variable determining the camera height offset to Camera's Z value minus Hero's Z position.
Third: A variable determining to how much to set a camera's Z to be the same as unit's. Set that variable to:
20 (OR OTHER ANY NUMBER) (YOU SHOULD PLAY AROUND WITH IT TO GET THE RIGHT ONE)
PLUS
VARIABLE DETERMINING CAMERA HEIGHT OFFSET
PLUS
HERO'S Z POSITION
MINUS
128 MULTIPLIED BY THE MOST COMMON CLIFF LEVEL OF YOUR ENTIRE MAP OR THE CLIFF LEVEL ON WHICH THE HERO IS STANDING

and the camera will go up into hills with hero. do that counting every 0.01 second, or at least every 0.1 second do avoid lag.
 
Status
Not open for further replies.
Top