System Arrow Key Third Person Camera System

Reaction score
341
I made this system a while ago , except it was in GUI and had alot of leaks. Now i have re-made it in JASS and made it more efficient and faster. What it does is it moves the camera around your unit using the arrow keys.


Demo
Download

Video ... Poor Quality

[YOUTUBE]<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/_zycqC4AD8c&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/_zycqC4AD8c&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>[/YOUTUBE]​

Anyways Code..

JASS:
scope AKC initializer InitTrig

globals
    private boolean array Left
    private boolean array Right
    private boolean array Up
    private boolean array Down
    private real array AOA
    private real array Rot
    private boolean array on
    private constant real time = 0.01 // refresh rate.
    private constant real rate = 1.00 // how fast the camera turns
endglobals

private function Init takes nothing returns nothing
    local integer i = 0
    loop
      exitwhen i &gt; 11
       set AOA<i> = -20
       set Rot<i> = GetUnitFacing(udg_PlayersHero[i + 1])
       set on<i> = true
       set i = i + 1
    endloop
endfunction

function ToggleCam takes player p returns nothing
    set on[GetPlayerId(p)] = not on[GetPlayerId(p)]
endfunction

private function LockCam takes nothing returns nothing
    local integer i = 0
    loop
      exitwhen i &gt; 11
      if on<i> == true then
      if udg_PlayersHero[i + 1] != null then
        if Player(i) == GetLocalPlayer() then
          call SetCameraTargetController(udg_PlayersHero[i + 1], 0, 0, true)
          call SetCameraField(CAMERA_FIELD_ROTATION, Rot<i>, 0.00)
          call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, AOA<i>, 0)
        endif 
       if Left<i> == true then
         set Rot<i> = Rot<i> + rate
       endif
       if Right<i> == true then
         set Rot<i> = Rot<i> - rate
       endif
       if Up<i> == true then
        if AOA<i> &lt; -9 then
         if AOA<i> &gt; -165 then
         set AOA<i> = AOA<i> - rate
        endif
        endif
       endif
       if Down<i> == true then
        if AOA<i> &lt; -9 then
         if AOA<i> &gt; -165 then
         set AOA<i> = AOA<i> + rate
        endif
       endif
       endif
       endif
       endif
       
       set i = i + 1
    endloop
endfunction

private function Left_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetTriggerPlayer())
    if on<i> == true then
    if udg_PlayersHero[i + 1] != null then
    if Left[GetPlayerId(GetTriggerPlayer())] == false then
      set Left[GetPlayerId(GetTriggerPlayer())] = true
      set Rot<i> = Rot<i> + rate
      call SetCameraFieldForPlayer( Player(i), CAMERA_FIELD_ROTATION, Rot<i>, 0.00)
    else
      set Left[GetPlayerId(GetTriggerPlayer())] = false
    endif
    endif
    endif
endfunction

private function Right_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetTriggerPlayer())
    if on<i> == true then
    if udg_PlayersHero[i + 1] != null then
    if Right[GetPlayerId(GetTriggerPlayer())] == false then
      set Right[GetPlayerId(GetTriggerPlayer())] = true
      set Rot<i> = Rot<i> - rate
      call SetCameraFieldForPlayer( Player(i), CAMERA_FIELD_ROTATION, Rot<i>,time)
    else
      set Right[GetPlayerId(GetTriggerPlayer())] = false
    endif
    endif
    endif
endfunction

private function Up_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetTriggerPlayer())
    if on<i> == true then
    if udg_PlayersHero[i + 1] != null then
    if Up[GetPlayerId(GetTriggerPlayer())] == false then
      set Up[GetPlayerId(GetTriggerPlayer())] = true
      set AOA<i> = AOA<i> - rate
      call SetCameraFieldForPlayer( Player(i), CAMERA_FIELD_ROTATION, Rot<i>, time)
    else
      set Up[GetPlayerId(GetTriggerPlayer())] = false
    endif
    endif
    endif
endfunction

private function Down_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetTriggerPlayer())
    if on<i> == true then
    if udg_PlayersHero[i + 1] != null then
    if Down[GetPlayerId(GetTriggerPlayer())] == false then
      set Down[GetPlayerId(GetTriggerPlayer())] = true
      set AOA<i> = AOA<i> + rate
      call SetCameraFieldForPlayer( Player(i), CAMERA_FIELD_ROTATION, Rot<i>, time)
    else
      set Down[GetPlayerId(GetTriggerPlayer())] = false
    endif
    endif
    endif
endfunction

//===========================================================================
private function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    local integer i = 0
    loop 
      exitwhen i &gt; 11
       call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_LEFT_DOWN)
       call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_LEFT_UP)
       set i = i + 1
    endloop
    call TriggerAddAction( t, function Left_Actions )
    set i = 0
    set t = CreateTrigger()
    loop
      exitwhen i &gt; 11
       call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_RIGHT_DOWN)
       call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_RIGHT_UP)
       set i = i + 1
    endloop
    call TriggerAddAction( t, function Right_Actions )
    set i = 0
    set t = CreateTrigger()
    loop
      exitwhen i &gt; 11
       call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
       call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_UP_UP)
       set i = i + 1
    endloop
    call TriggerAddAction( t, function Up_Actions )
    set i = 0
    set t = CreateTrigger()
    loop
      exitwhen i &gt; 11
       call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_DOWN_UP)
       call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
       set i = i + 1
    endloop
    call TriggerAddAction( t, function Down_Actions )
    set t = CreateTrigger()
    call TriggerRegisterTimerEvent( t, time, true)
    call TriggerAddAction(t, function LockCam)
    set t = CreateTrigger()
    call TriggerRegisterTimerEvent( t, 0.00, false)
    call TriggerAddAction(t, function Init)
endfunction

endscope
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
 

saw792

Is known to say things. That is all.
Reaction score
280
Why is this any better than other systems already made, such as AceHart's Third Person Camera System?

EDIT: In case there is any confusion, I am asking you to provide a comparison between other systems (that may have different features) and yours in your first post. I am aware that AceHart's system uses arrow keys to move the camera, not the unit.
 

D.V.D

Make a wish
Reaction score
73
I like this system because you can fully control the camera in game and it moves smovely. Acehart's system is also good and useful for RPG's but this one is used for pretty much anything else.
 
Reaction score
341
Aceharts only rotates around the unit. This one can move at any angle. So you can look at the top of your unit , or the back. Its up to you.
 

Leazy

You can change this now in User CP.
Reaction score
50
The download link does not seam to work, or do I have to register at that page? Would be better with a direct link in that case =) Seams fine judging the youtube movie, +rep.
 

XxShadyxX

I abused the rep system.
Reaction score
81
How Do I edit the zoom of the mouse wheel and also how do i set up the camara? I want it to be more rpg style very close to the unit
 

D.V.D

Make a wish
Reaction score
73
Imposible unless your using Renevaiting The Craft which everyoe who's playing needs to have to use the custom natives.
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top