First person multiplayer issues.

ShadowSnipe4

New Member
Reaction score
4
okay, I made a set of triggers for my first person camera views, and they work fine in single player. So I was all happy thinking I had finally gotten it to work. :D
But then I tried to play it on bnet with a friend earlier today and to my horror, the cameras messed up and only looked at the wrong direction etc. I tried it in single player again and it worked fine. I've spent a long time working on this stupid trigger and it seems like I'll never get it right. Hopefully someone can give me some insight as to why the crappy thing wont work. :banghead:

Heres the code.
Code:
function Trig_First_Person_View_Target_Actions takes nothing returns nothing
    local integer currentPlayer = 0
    local unit currentUnit = null
    local location currentPosition = null
    local location positionToMoveTo = null
    local unit cameraUnit = null
    loop
        set currentUnit = udg_MoveUnit[currentPlayer + 1]
        set cameraUnit = udg_CameraUnit[currentPlayer + 1]
        if currentUnit != null then
        set currentPosition = GetUnitLoc(currentUnit)
        set positionToMoveTo = PolarProjectionBJ(currentPosition, 64, GetUnitFacing(currentUnit))
            call SetUnitPositionLocFacingBJ(udg_CameraUnit[currentPlayer + 1], positionToMoveTo, GetUnitFacing(currentUnit))
            call RemoveLocation(currentPosition)
            set currentPosition = null
            call RemoveLocation(positionToMoveTo)
        endif
            set positionToMoveTo = null
        set currentPlayer = currentPlayer + 1
        exitwhen currentPlayer > 9
    endloop
    set currentUnit = null
    set cameraUnit = null
endfunction

//======================================================================  =====
function InitTrig_First_Person_View_Target takes nothing returns nothing
    set gg_trg_First_Person_View_Target = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_First_Person_View_Target, 0.05 )
    call TriggerAddAction( gg_trg_First_Person_View_Target, function Trig_First_Person_View_Target_Actions )
endfunction

And

Code:
function Trig_First_Person_View_Actions takes nothing returns nothing
    local integer currentPlayer = 0
    local unit cameraUnit = null
    local location currentPosition = null
    loop
        set cameraUnit = udg_CameraUnit[currentPlayer + 1]
        set currentPosition = GetUnitLoc(cameraUnit)
        if cameraUnit != null then
        call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(cameraUnit), 0.05)
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 100, 0.05)
        call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, 3, 0.05)
        call SetCameraField(CAMERA_FIELD_ZOFFSET, 83, 0.05)
        call PanCameraToTimedLocForPlayer(Player (currentPlayer + 1), currentPosition, .05)
        call SetCameraTargetControllerNoZForPlayer( Player (currentPlayer), udg_CameraUnit[currentPlayer + 1], 0, 0, false )
    endif
        set cameraUnit = null
        call RemoveLocation(currentPosition)
        set currentPosition = null
        set currentPlayer = currentPlayer + 1
        exitwhen currentPlayer > 9
    endloop
endfunction

//======================================================================  =====
function InitTrig_First_Person_View takes nothing returns nothing
    set gg_trg_First_Person_View = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_First_Person_View, 0.05 )
    call TriggerAddAction( gg_trg_First_Person_View, function Trig_First_Person_View_Actions )
endfunction
 

Rad

...
Reaction score
228
Stupid JASS. Anyways there has been some fps camera tutorials (If not here then wc3sear.ch) and I think theres some stuff in the free trigger code. Sorry I cant help with JASS
 

ShadowSnipe4

New Member
Reaction score
4
I'm still having problems with this if anyone has any thoughts...

Edit: Also, the thing in the free trigger code was no help. It used different preset cameras for each direction and overcomplicated it. (This coming from someone who used a long jass code instead :p )
 
P

Proserpine

Guest
Tip dont use the 3rd person in the free trigger code because i have the same problem like you with that one. And sry cant understand jass.
 

Rad

...
Reaction score
228
People do understand JASS Im sure, hell I've seen many guests who knew JASS (Which is totally embarassing :banghead: ). I have a first person camera demo map, forgot who made it only used it once a long time ago but it was like...

Code:
E: Time elapsed in the game equal to <2 seconds>
A: For each integer A 1-<# of players> do Actions-
--A: If Number of units in <Units selected by player [integer A]> equal to 1 then do Set <CameraTarget> = <SelectedUnit> else do do nothing
--A: <Bunch of camera triggers, lock to unit, rotate, etc>
A: Wait .3 seconds
A: Run (This trigger) checking conditions

Something like that, spent about 10 minutes looking for the map couldnt find it so this will just give you the jist, also you may want CameraTarget as an array ;)
 

DM Cross

You want to see a magic trick?
Reaction score
567
http://www.thehelper.net/forums/showpost.php?p=65716&postcount=2

Locate and download the map with the Third Person Camera trigger in it at the bottom of this post. Take the trigger work and put it in your map, then mess with the angle and whatnot until you get what you seek.

If you have more problems, then post again :)
 

ShadowSnipe4

New Member
Reaction score
4
Well, modifying the third person view one didnt really help, it just got me to where i was before I tried it. Also, I did some testong and now I found out that the camera works for only one player. For some reason it worked for blue but for me it had the same angle as his but near my unit making it so that it wasnt viewing the right way for me but was good for him.
 
S

Sanitarium

Guest
It works in Single Player?

Perhaps I'm spacing out but....If current unit is facing left and you move the camera unit 64 units in front of it, wouldn't you want to camera unit to face right, not left?
Code:
set positionToMoveTo = PolarProjectionBJ(currentPosition, 64, GetUnitFacing(currentUnit))
call SetUnitPositionLocFacingBJ(udg_CameraUnit[currentPlayer + 1], positionToMoveTo, GetUnitFacing(currentUnit))

It seems like the above code sets them both facing the same way...which could be a problem...but it works in Single Player right?
 

ShadowSnipe4

New Member
Reaction score
4
I dont really get what your saying...if the currentunit faces left, then the camera unit faces left and the camera faces left...why would i want it to face right?

Also, yes it does work in single player.
 
S

Sanitarium

Guest
MIsunderstanding

Ah, miss understanding, heh, I thought you wanted the camera to look at the unit...my bad. From what you've said..I have no idea.

Well, consider this a bump then. Gl with it.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Code:
        call PanCameraToTimedLocForPlayer(Player (currentPlayer + 1), currentPosition, .05)

I think this is the problem.

Player(0) == Player 1 (Red)
Player(1) == Player 2 (Blue)
ect.

So if udg_CameraUnit[ 1] belongs to player 1 you should have
Player(currentPlayer) only


Edit found some other things that probebly is the actualy problem
Code:
        call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(cameraUnit), 0.05)
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 100, 0.05)
        call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, 3, 0.05)
        call SetCameraField(CAMERA_FIELD_ZOFFSET, 83, 0.05)
This makes it for all players, for the 3 last things there is no problem, just unneded. But for
Code:
        call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(cameraUnit), 0.05)
well... All players will have the rotation of the last current unit. Use SetCameraFieldForPlayer() or make all camera changes in a GetLocalPlayer() block.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top