wellwish3r
wishes wells.
- Reaction score
- 52
Im working on a 3rd person cam system, so far it woks fine except for one thing. The Z elevation of the camera goes way to high when the unit that it is locked on goes on raised terrain. It works fine when walks up standard cliffs, just not on raised terrain... I dont know why.
EDIT: Only happens on very steep raised terrain.
JASS:
scope Camera initializer Init
struct cam
unit locked
real distance
real angle
location loc
endstruct
globals
private integer Total = 11
private cam array D
private timer T = CreateTimer()
endglobals
private function TimerLoop takes nothing returns nothing
local integer i = 0
local real z
loop
exitwhen i>=Total
if D<i>.locked != null then
set D<i>.loc = GetUnitLoc(D<i>.locked)
set z = GetLocationZ(D<i>.loc)
if (GetLocalPlayer() == Player(i)) then
call PanCameraToTimed(GetLocationX(D<i>.loc), GetLocationY(D<i>.loc), 1)
endif
if (GetLocalPlayer() == Player(i)) then
call SetCameraTargetController(D<i>.locked, 0, 0, false)
endif
if (GetLocalPlayer() == Player(i)) then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, D<i>.distance, .75)
endif
if (GetLocalPlayer() == Player(i)) then
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, D<i>.angle, .75)
endif
if (GetLocalPlayer() == Player(i)) then
call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(D<i>.locked), .75)
endif
if (GetLocalPlayer() == Player(i)) then
call SetCameraField(CAMERA_FIELD_ZOFFSET, 180+(z/3), .75)
endif
call RemoveLocation(D<i>.loc)
endif
set i = i+1
endloop
endfunction
private function TurnAct takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
call SetUnitFacing(D<i>.locked,GetUnitFacing(D<i>.locked)-180)
endfunction
private function Turn takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i>11
call TriggerRegisterPlayerKeyEventBJ(t,Player(i),bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN)
set i = i+1
endloop
call TriggerAddAction(t,function TurnAct)
endfunction
private function Init takes nothing returns nothing
call Turn()
call TimerStart(T,0.03,true,function TimerLoop)
endfunction
function SetCamTarget takes unit u, real dist,real angle, integer i returns nothing
set D<i>.locked = u
set D<i>.distance = dist
set D<i>.angle = angle
endfunction
endscope
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
EDIT: Only happens on very steep raised terrain.