| 10-22-2006, 10:22 PM | #1 |
I'm trying to keep the camera at a constant absolute height ignoring the terrain. In other words: if you scroll over a map with cliffs and other changes in terrain height, you should have the feeling that you are just changing your position in a horizontal way, without changing it in any vertical way. So how can I get this to work fluently? I wrote the following script: JASS:function CamZCorrect takes nothing returns real return GetCameraField( CAMERA_FIELD_ZOFFSET ) - GetCameraEyePositionZ() - Sin( GetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK ) ) * GetCameraField( CAMERA_FIELD_TARGET_DISTANCE ) endfunction function Constant_Height_Actions takes nothing returns nothing call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_ZOFFSET, 1300 + CamZCorrect(), 0 ) endfunction //=========================================================================== function InitTrig_Constant_Height takes nothing returns nothing set gg_trg_Constant_Height = CreateTrigger( ) call TriggerRegisterTimerEventPeriodic( gg_trg_Constant_Height, 0.015 ) call TriggerAddAction( gg_trg_Constant_Height, function Constant_Height_Actions ) endfunction Well, it works, but only more or less. When I'm scrolling over cliffs, the view gets shaking, the steeper the terrain, the stronger the shaking. If I set the frequence of the event to 0.01 or less, it is just weird stuff ingame - it doesn't work at all anymore. Any ideas how to get this working in a way that the watcher just can feel he is flying as described above without shaking view? Where does it come from? The Trigger is working indepently so just try it out in a new map by yourself! ![]() |
| 10-23-2006, 11:20 AM | #2 |
Use GetLocationZ instead of GetCameraEyePositionZ |
| 10-23-2006, 02:23 PM | #3 |
Well, I don't understand what exactly I should replace with GetLocationZ, but it will not work anyways, I think because I have to correct the change of the camera pathing map, not the change of the terrain height, right? I got the tip with GetCameraEyePositionZ from TheEpigoni's FPSCamera Tutorial. |
| 10-23-2006, 02:47 PM | #4 |
For some odd reason a camera with 90 Zoffset returns an different Z value then an terrain with 90 Zoffset |
| 10-23-2006, 05:52 PM | #5 |
Yes, that's because the camera is following an own, somehow smoothened path map to prevent it from jumping with the height of every little mini cliff. The construction with the GetCameraEyePositionZ (which is absolutely correct) and the sin things is to get the real z-offset of the camera, not the one of the terrain (which is different, as I tried to explain). [I hope I understood you the right way] |
