Camera z-offset over terrain

Status
Not open for further replies.
Level 3
Joined
Jan 20, 2020
Messages
48
Hey all - I'm trying to develop a third person camera, and right now the thing that is destroying it is that the camera's z elevation changes dynamically based on terrain hills and valleys irregardless of the Height Offset parameter of the camera object. This results in the camera being way too low if its a hill, or far away if its a valley.

The editor added a nifty feature to get the z-elevation at a unit position - but this isn't really helpful to translate to the camera height offset because at the start the camera's height offset is zero whereas the unit's z elevation might be something much greater, like 400.

Is there any way to fix this, preferably with GUI? In SC2 it was easy as pie, you could just disable the camera's collision in the camera editor, and it was no longer affected by the terrain height.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I'm no expert on Cameras but I found this:
  • Set Variable Z = (Source Z of current camera view)
Also, you can get the Z of any given point:
  • Actions
    • Set Variable Point = (Source of current camera view)
    • Custom script: set udg_Z = GetLocationZ(udg_Point)
Not sure how "Source of current camera view" works with multiple players but you could always set the Point to be the position of your Hero and then set the angle/offset to be the same as the cameras. In other words, create the Point at the position of your Camera, get the Z of that point, and adjust the camera accordingly.
 
Last edited:
Level 3
Joined
Jan 20, 2020
Messages
48
I'm no expert on Cameras but I found this:
  • Set Variable Z = (Source Z of current camera view)
Also, you can get the Z of any given point:
  • Actions
    • Set Variable Point = (Source of current camera view)
    • Custom script: set udg_Z = GetLocationZ(udg_Point)
Not sure how "Source of current camera view" works with multiple players but you could always set the Point to be the position of your Hero and then set the angle/offset to be the same as the cameras. In other words, create the Point at the position of your Camera, get the Z of that point, and adjust the camera accordingly.

What would I apply the corrected Z to though? It only gives you the option to modify the Height Offset; but you could literally have a Height Offset = 0 and the camera will not account for the terrain hill/valley (i.e. 0 height is still floating high above the terrain if you are in a valley; and you can't have a negative Height Offset).
 
Level 3
Joined
Jan 20, 2020
Messages
48
Perhaps a negative offset. Not sure, haven't messed around with it much.

just wanted to let you know that i finally got this working, at least for one player. I run a periodic event trigger where I set a variable which is the height difference between the camera source and the unit's z elevation, let's call it Zvar. Then i reset the user's camera offset to (current height offset) + (X - Zvar); where X is the height offset that you want to remain constant (usually around 100 for a third person game with normal sized units).

thanks for all your replies!
 
just wanted to let you know that i finally got this working, at least for one player. I run a periodic event trigger where I set a variable which is the height difference between the camera source and the unit's z elevation, let's call it Zvar. Then i reset the user's camera offset to (current height offset) + (X - Zvar); where X is the height offset that you want to remain constant (usually around 100 for a third person game with normal sized units).

thanks for all your replies!
Would you mind posting your trigger? I am really interested in this actually, because I'm having some of the same issues.
 
Status
Not open for further replies.
Top