• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Following Camera

Status
Not open for further replies.
Level 7
Joined
Jul 14, 2006
Messages
292
Hi there! I'm currently working on a project. And I'd like to ask a question.

You see, each player will control 1 unit. And I'd like the camera to follow the unit from behind, so their vision would be restricted to what the unit see in front of him. I made the camera, they are a little higher over the ground. and they are well oriented. But when I lock the camera to the unit, using the unit's orientation, it just follow it but it don't rotate. So I'm kind of disapointed :/... I tried almost anything I knew but couldn't solve the problem. I oppenned Azeroth Grand Prix by Blizzard to see how the camera follow the cars but couldn't find out. Could you help me plz?
 
This way, camera elevates together with unit, just cnp to blank trigger

JASS:
function Trig_CameraFollowing_Actions takes nothing returns nothing
    local location l
    local integer i
    set i = 1
    loop
        exitwhen i > 10
        set l = GetUnitLoc(udg_Player[i])
        call SetCameraFieldForPlayer( ConvertedPlayer(i), CAMERA_FIELD_TARGET_DISTANCE, 600.00, 0.10 )
        call SetCameraFieldForPlayer( ConvertedPlayer(i), CAMERA_FIELD_ANGLE_OF_ATTACK, 340.00, 0.10 )
        call SetCameraFieldForPlayer( ConvertedPlayer(i), CAMERA_FIELD_ROTATION, GetUnitFacing(udg_Player[i]), 0.30 )
        call SetCameraFieldForPlayer( ConvertedPlayer(i), CAMERA_FIELD_ZOFFSET, 75 + (GetLocationZ(l) / 2), 0.20 )
        set i = i + 1
    endloop
    call RemoveLocation(l)
    set l = null
endfunction
function InitTrig_CameraFollowing takes nothing returns nothing
    set gg_trg_CameraFollowing = CreateTrigger()
    call TriggerAddAction( gg_trg_CameraFollowing, function Trig_CameraFollowing_Actions )
    call TriggerRegisterTimerEvent(gg_trg_CameraFollowing, 0.1,true) 
endfunction

i know you probbably requested gui, but this works almost same way as gui :p
 
mozes samo da se slikas ? = serbian fraze, means "wont work"

well, you have to set your unit as variable "udg_Player[1]" and rest so you can use this system, but first you have to lock camera to unit (this is part of huge system, i forgot to add camera locking here XD)

>>But dude you just set the camera to the right distance and stuff and then LOCK it on the unit (i supposed u use variables for that) and then it doesnt work?<<

no, you have to set parameters over time to make this work, just locak camera to unit, cnp this trigger, in variables add unit array "udg_Player" and set unit that is supposed to move to "Player[1]" for single player or "Player" for multiplayer

>>call SetCameraFieldForPlayer( ConvertedPlayer(i), CAMERA_FIELD_ZOFFSET, 75 + (GetLocationZ(l) / 2), 0.20 )

Is that what ur talking about? hmmm I dont understand JASS that well, what makes the z offset change?<<

"z" in math means "height" so it changes (height of camera to height of terrain + 75)
 
Status
Not open for further replies.
Top