- Joined
- Jan 11, 2009
- Messages
- 3,414
Hello everyone!
I am having some problem with my camera system. My library looks like this:
Before you say anything, i KNOW i don't have to set camera target every loop, i am just to lazy to look up everywhere i change the CAN_CONTROL variable and put it there. I also know that capital letter names are for constants, but sloppy and inconsistent is just the way i am.
NOW here's my problem:
I have a custom destructable-based menu that you use before the game starts. It is for this one that i have to set wether player can control camera or not. As you can see, the two options also have different camera heights.
This all works well the first time, but:
a) when i go back to the menu (set CAN_CONTROL = false), the camera distance is all wrong and too far away.
b) when i scroll while CAN_CONTROL = true, the camera goes down to normal height again.
I seriously don't know what is wrong here, so please help me out!
I am having some problem with my camera system. My library looks like this:
JASS:
library Camera initializer Init
globals
private timer T = CreateTimer()
constant real MIN_DISTANCE = 250
constant real MAX_DISTANCE = 6500
real array CAM_DISTANCE[6]
boolean CAN_CONTROL = false
unit LockUnit
real CameraLockX = 16448.
endglobals
private function callback takes nothing returns nothing
local integer i = 0
if CAN_CONTROL == false then
call SetCameraTargetController(LockUnit, 0, 0, true)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, 270., 0)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 2600., 0)
call SetCameraField(CAMERA_FIELD_ROTATION, 90., 0)
else
loop
exitwhen i > 6
if GetLocalPlayer() == Player(i) then
call SetCameraField(CAMERA_FIELD_ZOFFSET, CAM_DISTANCE[i], 0 )
call SetCameraField(CAMERA_FIELD_FARZ, 10000.00, 0 )
endif
set i = i+1
endloop
endif
endfunction
private function Init takes nothing returns nothing
local integer i = 0
set LockUnit = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'h00G', CameraLockX, 548., 90)
call TimerStart(T, 0.10, true, function callback)
loop
exitwhen i > 6
set CAM_DISTANCE[i] = 900
endloop
endfunction
endlibrary
Before you say anything, i KNOW i don't have to set camera target every loop, i am just to lazy to look up everywhere i change the CAN_CONTROL variable and put it there. I also know that capital letter names are for constants, but sloppy and inconsistent is just the way i am.
NOW here's my problem:
I have a custom destructable-based menu that you use before the game starts. It is for this one that i have to set wether player can control camera or not. As you can see, the two options also have different camera heights.
This all works well the first time, but:
a) when i go back to the menu (set CAN_CONTROL = false), the camera distance is all wrong and too far away.
b) when i scroll while CAN_CONTROL = true, the camera goes down to normal height again.
I seriously don't know what is wrong here, so please help me out!