• 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.

Help with camera

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
This is a bit dumb, but I forgot how to play with camera and triggers

I'd like to change camera distance from 2000 to 5000 with -zoom ####
I also want to change the Angle of the camera from default (around 70) to 90 with -angle ##

I'd also want to enable Camera lock (with it's current distance and it's current attack angle) to the player hero with -lock

So players can text "-Zoom 3200" "-Angle 88" "-lock" and have it's camera Locked to it's hero with 3200 distance and 88 angle, and make it stay as it's, even if the player moves the mousewheel.

Thanks for reading!
 
Here you go with triggers and a test map.
When you lock it will lock to the last values of angle and distance, as I don't really seem to find 'the current distance from current camera' trustworthy as you can't configure it for a specific unit even though it produces as a real.
  • Init Players
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set PlayerGroup = (All players matching (((Matching player) controller) Equal to User))
      • Player Group - Pick every player in PlayerGroup and do (Actions)
        • Loop - Actions
          • Trigger - Add to Chat <gen> the event (Player - (Picked player) types a chat message containing - as A substring)
      • Custom script: call DestroyForce(udg_PlayerGroup)
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
      • Camera - Set (Picked player)'s camera Distance to target to Zoom[Integer] over 0.09 seconds
  • Chat
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • -zoom Equal to (String((Substring((Entered chat string), 1, 5))) as Lower case)
        • Then - Actions
          • Set Integer = (Player number of (Triggering player))
          • Set Zoom[Integer] = (Real((Substring((Entered chat string), 7, (Length of (Entered chat string))))))
          • Camera - Set (Triggering player)'s camera Distance to target to Zoom[Integer] over 0.09 seconds
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • -angle Equal to (String((Substring((Entered chat string), 1, 6))) as Lower case)
            • Then - Actions
              • Set Integer = (Player number of (Triggering player))
              • Set Angle[Integer] = (Real((Substring((Entered chat string), 8, (Length of (Entered chat string))))))
              • Camera - Set (Triggering player)'s camera Rotation to Angle[Integer] over 0.09 seconds
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • -lock Equal to (String((Entered chat string)) as Lower case)
                • Then - Actions
                  • Player Group - Add (Triggering player) to LockedPlayers
                  • Trigger - Turn on Lock <gen>
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • -unlock Equal to (String((Entered chat string)) as Lower case)
                    • Then - Actions
                      • Player Group - Remove (Picked player) from LockedPlayers
                    • Else - Actions
Initially off
  • Lock
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Boolean = False
      • Player Group - Pick every player in LockedPlayers and do (Actions)
        • Loop - Actions
          • Set Integer = (Player number of (Picked player))
          • Camera - Set (Picked player)'s camera Distance to target to Zoom[Integer] over 0.03 seconds
          • Camera - Set (Picked player)'s camera Rotation to Angle[Integer] over 0.03 seconds
          • Set Boolean = True
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Boolean Equal to False
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
Made from scratch.
 

Attachments

  • Camera.w3x
    17.8 KB · Views: 50
Level 20
Joined
Jul 14, 2011
Messages
3,213
Thanks!

Didn't do it exactly as you posted, but helped me a lot.

JASS:
function Trig_Camera_Actions takes nothing returns nothing
    local string s = GetEventPlayerChatString()
    local player p = GetTriggerPlayer()
    local player lp = GetLocalPlayer()
    local integer pi = GetPlayerId(p) + 1
    local integer i = StringLength(s)
    
    if SubString(s, 0, 4) == "-cam" then
        call DisplayTimedTextToPlayer(p, 0, 0, 10, " |cffffcc00-cam|r displays this information")
        call DisplayTimedTextToPlayer(p, 0, 0, 10, " |cffffcc00-zoom ####|r changes camera distance")
        call DisplayTimedTextToPlayer(p, 0, 0, 10, " |cffffcc00-angle ###|r changes camera angle of attack")
        call DisplayTimedTextToPlayer(p, 0, 0, 10, " |cffffcc00-lock|r locks the camera to your unit with your settings")
        call DisplayTimedTextToPlayer(p, 0, 0, 10, " |cffffcc00-unlock|r unlocks the camera")
        call DisplayTimedTextToPlayer(p, 0, 0, 10, " |cffffcc00-clear|r removes any screen message")
    elseif if SubString(s, 0, i) == "-clear" then
        if lp = p then
            call ClearTextMessages()
        endif
    elseif SubString(s, 0, 5) == "-zoom" then
        set udg_Zoom[pi] = S2R(SubString(s, 6, i))
        if lp == p then
            call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, udg_Zoom[pi], 1)
        endif
        call DisplayTimedTextToPlayer(p, 0, 0, 5, "Camera distance set to: " + SubString(s, 6, i))
    elseif SubString(s, 0, 6) == "-angle" then
        set udg_Angle[pi] = S2R(SubString(s, 7, i))
        if lp == p then
            call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, udg_Angle[pi], 1)
        endif
        call DisplayTimedTextToPlayer(p, 0, 0, 5, "Camera angle set to: " + SubString(s, 7, i))
    elseif s == "-lock" then
        call ForceAddPlayer(udg_LockedPlayers, p)
        call EnableTrigger( gg_trg_Camera_Lock )
        call DisplayTimedTextToPlayer(p, 0, 0, 5, "Camera Locked")
    elseif s == "-unlock" then
        call ForceRemovePlayer(udg_LockedPlayers, p)
        call DisplayTimedTextToPlayer(p, 0, 0, 5, "Camera Unlocked")
    endif
    set s = null
    set p = null
endfunction

JASS:
function Camera_Lock_GroupActions takes nothing returns nothing
    local player p = GetEnumPlayer()
    local integer pi = GetPlayerId(p)+1
    
    if GetLocalPlayer() == p then
        call SetCameraTargetController(udg_Bomber[pi], 0, 0, false)
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, udg_Zoom[pi], 0.1)
        call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, udg_Angle[pi], 0.1)
    endif
endfunction

function Trig_Camera_Lock_Actions takes nothing returns nothing
    set bj_forceCountPlayers = 0
    call ForForce(udg_LockedPlayers, function CountPlayersInForceEnum)
    if bj_forceCountPlayers > 0 then    
        call ForForce( udg_LockedPlayers, function Camera_Lock_GroupActions )
    else
        call DisableTrigger( gg_trg_Camera_Lock )
    endif
endfunction
 
Status
Not open for further replies.
Top