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
 
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
 
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 )
 
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.
 
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 ;)
 
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 :)
 
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.
 
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?
 
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.
 
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.
 
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.
  • Ghan Ghan:
    Probably inflates their numbers so they look better to advertisers.
  • The Helper The Helper:
    Yeah google does not filter those bots. I remember when Apex was doing Google ads I saw the same IPs in there as I was seeing here - google is totally tracking all those bots as traffic and most google traffic, at least ours, was all bots
  • The Helper The Helper:
    oh wow, i bet i can post x links now and do the webp pics now giggity
  • The Helper The Helper:
    ahh anubis blocks anyone that has javascript turned off
  • The Helper The Helper:
    Robot: HTTP client library - i love the new robot :)
  • The Helper The Helper:
    New Science News Forum and it starts out with 420 threads :)
  • The Helper The Helper:
    Technical Support forum name changed To Technology News, there is now a Tech, sci/tech and science forums now :)
  • The Helper The Helper:
    Happy Saturday! Hope everyone has a fantastic weekend!
  • Ghan Ghan:
    We are now on Ubuntu 24.04. Had some issues with the style after the OS/PHP upgrade but now resolved.
    +1
  • Ghan Ghan:
    PHP 8.3 now live
    +1
  • The Helper The Helper:
    Weekend went by too fast. Next weekend I am going to try to do a nature thing - buddy of mine lives by the Colorado river and has some kayaks and invited me to do some kayaking from a place he knows to get on the river.
  • Ghan Ghan:
    That sounds like an adventure.
  • The Helper The Helper:
    400 users all online all looking at latest content
  • The Helper The Helper:
    I wonder how all these bots that sit on the lastest content page get passed anubis or maybe they did not but they are just registering on whos online
  • The Helper The Helper:
    showing up on whos online not registration
  • Ghan Ghan:
    The first gate is stopping all the bots that don't execute javascript.
  • Ghan Ghan:
    That's the main thing with Anubis - no Javascript, no site. Typically you can still get the site to load without Javascript.
  • The Helper The Helper:
    I remember the whole javascript thing, question - how many real people disable that?
  • The Helper The Helper:
    Hell I guess I could go back on the stats to know that - we probably capture that and we know the before and after
  • Ghan Ghan:
    Real users can't really disable Javascript anymore these days.
  • Ghan Ghan:
    The internet is broken without it.
  • Ghan Ghan:
    Bot readable, not human usable.
  • The Helper The Helper:
    got it
  • The Helper The Helper:
    Happy Thursday!
  • The Helper The Helper:
    Check out the new Featured Content feature we apparently got with the forum software upgrade! https://www.thehelper.net/featured/

The Helper Discord

Members online

No members online now.

Affiliates

Hive Workshop NUON Dome World Editor Tutorials
Back
Top