Is there a way to get Z coordinat of a unit/region/point?

Insanewarlock

Active Member
Reaction score
2
I need the camera height offset to change when player walks up a mountain my third person map. How do I do set my HeightVar to the Z coordinate of the unit/hero?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
There is a way with jass, but not with GUI.
You first get the location of the unit / whatever. Then you can get the Z-coordinate of the location with getLocationZ (or something like that, not sure about the exact syntax).
 

Insanewarlock

Active Member
Reaction score
2
Do I need a JASS trigger or custom script is enough? What is this?
Code:
call SetCameraZ(GetEnumPlayer(), udg_playerCameraZ[GetConvertedPlayerId(GetEnumPlayer())]+128)
I fount it on the following map:
http://www.hiveworkshop.com/forums/map-development-202/third-person-shooter-test-map-127704/

I don't know JASS at all so that's why I'm asking the question. I know few programing languages but JASS is kinda confusing. Can you help?

And also somebody on this forum had made the camera height offset dependent on terrain height but I cant understand it at all.... I see your post there :D
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
You dont have to make the whole trigger in jass, a single line of custom code is enough.
The line should look somewhat like this:
Code:
set udg_SomeReal = GetLocationX(udg_SomePoint)
where SomeReal is some kind of real variable and SomePoint is some kind of point variable.
 

Insanewarlock

Active Member
Reaction score
2
Oh it didn't work.... Errors popped up. I created thre variables: Unit (var type unit), Unit_Point (var type point), and Unit_Height (var type real). I attached my hero to Unit in initialization than created 3 actions in periodic event:
Code:
Set Unit_Point = (Position of Unit)
Custom script: set udg_Unit_Height = GetLocationX(udg_Unit_Point)
Camera - Set Player 1 (Red)'s camera Height Offset to (Unit_Height+130.00) over 0.1 seconds.
Whad did I do wrongly?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Works for me:
Code:
Trigger
  Events
    Player - Player 1 (Red) selects a unit
  Conditions
  Actions
    Set Point = (Position of (Triggering unit))
    Custom script:  set udg_Real = GetLocationZ(udg_Point)
    Game - Display to (All players) the text: (String(Real))
 

Insanewarlock

Active Member
Reaction score
2
Thank you so much! Finally I've made but with a small issue as always.... :D The script looks like this:
(Only the height regulation part)
Trigger:
  • Events
    • Time - Every 0.10 seconds of game time

Trigger:
  • Actions
    • set Unit_Point = (Position of Unit)
    • Custom script: set udg_Unit_Height = GetLocationZ(udg_Unit_Point)
    • Camera - Set Player 1 (Red)'s camera Height Offset to (180.00 + (0.02 x Unit_Height)) over 0.10 seconds


It took a long time to figure out this linear function: 180 + (0.02 x Unit_Height) and it's very good when the terrain is flat and wide enough, but if the area is small sized the game seems to be regulating height without my request, looks like auto height offset correction. How do I turn that off? Don't think that Z coordinate (Unit_Height) is not changing when that happens, it does, I've checked, there is some kind of auto regulation, I've spotted it even when this height offset regulation (script shown above) was turned off and offset was constant.

And the other (final) issue I have, which is a wholly different question (should I make a different thread about it? First help me formulate the question or give me hints please if you don't know how to solve it), how should my camera avoid other objects like mountains and trees? The problem is not that big because besides camera rotating according to unit's facing angle, I created camera rotation with arrow control <- ^ v -> and you can simply avoid moments when camera crushes into something, but you still see these moments when it happens before you try to rotate the camera and it looks pretty ugly. Do you have any ideas? "Ultimate Third Person Camera" claims to have solved it, how did he do that?

Again, I'm really grateful for your help!
 
Last edited:

Accname

2D-Graphics enthusiast
Reaction score
1,462
I think you are talking about the cliffs. Cliffs in wc3 will make the camera go higher automatically. I dont know if there is much you can do except take the cliff level of the unit into consideration, but that will probably still not be accurate all the time.
 

Insanewarlock

Active Member
Reaction score
2
I think you are talking about the cliffs.
Yes, yes!
take the cliff level of the unit into consideration
I don't seem to understand you, what is the cliff level of the unit?

I could mark every region containing cliffs and set different height offset there for camera but it's not really that bad I think. I'll just make a map with less cliffs =D But what about the other problem? When camera is looking underground? I partially solved the problem by changing distance to target and angle of attack so it's happening less often. Maybe it would be better to leave the script simple. Check it out how would you rate it out of 10? :D Don't forget to rotate camera with arrows.

https://drive.google.com/file/d/0B9pUVpJO3AdqV2g1QUthZlJ1VWM/edit?usp=sharing
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
You can get the cliff level (height of cliff) at a certain location. For example at the location of the unit.
Each cliff level has a height of 128. So if you take the cliff level at the units location, multiply it with 128 and subtract that value from your cameras Z value you might get closer to what you want.
But the problem is that the units location is not the location of the camera. It would be more accurate if you can find the location of the camera and use the cliff level at that point for your calculation.

In pseudo-code this might look somewhat like this:
Code:
unitLoc = position of unit
camLoc = unitLoc offset by CAM_DISTANCE towards (CAM_ANGLE - 180) degres
cliffLvl = get cliff level at camLoc
unitZ = get location Z for unitLoc
camZ = CAM_HEIGHT_FIX + unitZ - (cliffLvl * 128)

Experiment with the values, of course, but this might help you a little bit.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top