Having trouble with 3rd person movement

PrisonLove

Hard Realist
Reaction score
78
Hey, so I used the tutorial in the tutorials section to create a third person movement system for my zealot using mouse look and WASD movement. I've run into a major problem.

When moving, the Zealot will only face the camera yaw if it is in the bottom left quadrant of the map. It's very strange and I don't know why it's happening. I was also able to replicate the problem, it seems as if the unit just stops facing the camera yaw after it hits a certain x, y point in the map. The replicated issue is in the 3PMovementTest map.

Could someone help me with this issue? I'll post the map as well as the triggers I'm using.

For Camera:

Trigger:
  • camTimer = (New timer) <Timer>
    • camPlayerGroup = (Empty player group) <Player Group>
    • camUnit = No Unit <Unit[16]>


Function setThirdPersonCamera
Trigger:
  • setThirdPersonCamera
    • Options: Action
    • Return Type: (None)
    • Parameters
      • unit = No Unit <Unit>
      • p = 0 <Integer>
    • Grammar Text: setThirdPersonCamera(unit, p)
    • Hint Text: (None)
    • Custom Script Code
    • Local Variables
    • Actions
      • Camera - Turn camera vertical field of view On for player p
      • Camera - Turn camera mouse rotation On for player p
      • Camera - Lock camera mouse relative mode On for player p
      • Camera - Set camera mouse Pitch rotation speed to 0.3 for player p
      • Camera - Set camera mouse Yaw rotation speed to 0.5 for player p
      • Camera - Turn camera height displacement Off for player p
      • Camera - Apply camera object Distance 7.0 for player p over 0.0 seconds with Existing Velocity% initial velocity and 10% deceleration
      • Camera - Apply camera object Angle Of Attack 20.0 for player p over 0.0 seconds with Existing Velocity% initial velocity and 10% deceleration
      • Camera - Apply camera object Height Offset 0.8 for player p over 0.0 seconds with Existing Velocity% initial velocity and 0% deceleration
      • Camera - Follow for player p (Unit group(unit)) with the camera and Clear Current Target
      • UI - Hide game UI for (Player group(p))
      • Variable - Set camUnit[p] = unit
      • Player Group - Add player p to camPlayerGroup

Function updateThirdPersonCamera
Trigger:
  • updateThirdPersonCamera
    • Options: Action
    • Return Type: (None)
    • Parameters
    • Grammar Text: updateThirdPersonCamera()
    • Hint Text: (None)
    • Custom Script Code
    • Local Variables
      • p = 0 <Integer>
      • faceAngle = 0.0 <Real>
    • Actions
      • Player Group - Pick each player in camPlayerGroup and do (Actions)
        • Actions
          • Variable - Set p = (Picked player)
          • Variable - Set faceAngle = (Current camera yaw of player p)
          • Camera - Apply camera object Distance 7.0 for player p over 0.0 seconds with Existing Velocity% initial velocity and 10% deceleration
          • Camera - Apply camera object Height Offset (0.8 - ((Air height at (Position of camUnit[p])) - (Ground height at (Position of camUnit[p])))) for player p over 0.0 seconds with Existing Velocity% initial velocity and 0% deceleration
          • Unit - Make camUnit[p] face faceAngle over 0.1 seconds

Function removeThirdPersonCamera
Trigger:
  • removeThirdPersonCamera
    • Options: Action
    • Return Type: (None)
    • Parameters
      • unit = No Unit <Unit>
      • p = 0 <Integer>
    • Grammar Text: removeThirdPersonCamera(unit, p)
    • Hint Text: (None)
    • Custom Script Code
    • Local Variables
    • Actions
      • Camera - Turn camera vertical field of view Off for player p
      • Camera - Turn camera mouse rotation On for player p
      • Camera - Lock camera mouse relative mode Off for player p
      • Camera - Stop Following for player p (Unit group(unit)) with the camera and Clear Current Target
      • Camera - Turn camera height displacement On for player p
      • UI - Show game UI for (Player group(p))
      • Player Group - Remove player p from camPlayerGroup


For Movement:

Trigger:
  • wKey = false <Boolean[16]>
    • aKey = false <Boolean[16]>
    • sKey = false <Boolean[16]>
    • dKey = false <Boolean[16]>


**Note: Setting the keys true and false are included and work fine so I'm not posting them**

Function updateThirdPersonMovement <--- I suspect the problem is here
Trigger:
  • updateThirdPersonMovement
    • Options: Action
    • Return Type: (None)
    • Parameters
    • Grammar Text: updateThirdPersonMovement()
    • Hint Text: (None)
    • Custom Script Code
    • Local Variables
      • p = 0 &lt;Integer&gt;
      • camAngle = 0.0 &lt;Real&gt;
      • moveAmount = 0.0 &lt;Real&gt;
    • Actions
      • Player Group - Pick each player in camPlayerGroup and do (Actions)
        • Actions
          • Variable - Set p = (Picked player)
          • Variable - Set camAngle = (Current camera yaw of player p)
          • Variable - Set moveAmount = ((camUnit[p] Movement Speed (Current)) * 0.0625)
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • Or
                • Conditions
                  • wKey[p] == true
                  • aKey[p] == true
                  • sKey[p] == true
                  • dKey[p] == true
            • Then
              • Animation - Play Walk animation for (Actor for camUnit[p]) as Default, using No Options options and Default Time blend time
              • General - If (Conditions) then do (Actions) else do (Actions)
                • If
                  • wKey[p] == true
                  • aKey[p] == false
                  • sKey[p] == false
                  • dKey[p] == false
                • Then
                  • Unit - Make camUnit[p] face camAngle over 0.1 seconds
                  • Unit - Move camUnit[p] instantly to ((Position of camUnit[p]) offset by moveAmount towards camAngle degrees) (Blend)
                • Else
            • Else
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • wKey[p] == true
              • aKey[p] == true
              • sKey[p] == false
              • dKey[p] == false
            • Then
              • Unit - Make camUnit[p] face (camAngle + 45.0) over 0.1 seconds
              • Unit - Move camUnit[p] instantly to ((Position of camUnit[p]) offset by moveAmount towards (camAngle + 45.0) degrees) (Blend)
            • Else
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • wKey[p] == true
              • aKey[p] == false
              • sKey[p] == false
              • dKey[p] == true
            • Then
              • Unit - Make camUnit[p] face (camAngle - 45.0) over 0.1 seconds
              • Unit - Move camUnit[p] instantly to ((Position of camUnit[p]) offset by moveAmount towards (camAngle - 45.0) degrees) (Blend)
            • Else
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • wKey[p] == false
              • aKey[p] == false
              • sKey[p] == false
              • dKey[p] == true
            • Then
              • Unit - Make camUnit[p] face (camAngle - 90.0) over 0.1 seconds
              • Unit - Move camUnit[p] instantly to ((Position of camUnit[p]) offset by moveAmount towards (camAngle - 90.0) degrees) (Blend)
            • Else
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • wKey[p] == false
              • aKey[p] == true
              • sKey[p] == false
              • dKey[p] == false
            • Then
              • Unit - Make camUnit[p] face (camAngle + 90.0) over 0.1 seconds
              • Unit - Move camUnit[p] instantly to ((Position of camUnit[p]) offset by moveAmount towards (camAngle + 90.0) degrees) (Blend)
            • Else
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • wKey[p] == false
              • aKey[p] == true
              • sKey[p] == true
              • dKey[p] == false
            • Then
              • Variable - Set moveAmount = (moveAmount * 0.8)
              • Unit - Make camUnit[p] face (camAngle - 45.0) over 0.1 seconds
              • Unit - Move camUnit[p] instantly to ((Position of camUnit[p]) offset by moveAmount towards (camAngle + 135.0) degrees) (Blend)
            • Else
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • wKey[p] == false
              • aKey[p] == false
              • sKey[p] == true
              • dKey[p] == true
            • Then
              • Variable - Set moveAmount = (moveAmount * 0.8)
              • Unit - Make camUnit[p] face (camAngle + 45.0) over 0.1 seconds
              • Unit - Move camUnit[p] instantly to ((Position of camUnit[p]) offset by moveAmount towards (camAngle - 135.0) degrees) (Blend)
            • Else
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • wKey[p] == false
              • aKey[p] == false
              • sKey[p] == true
              • dKey[p] == false
            • Then
              • Variable - Set moveAmount = (moveAmount * 0.8)
              • Unit - Make camUnit[p] face (camAngle + 0.0) over 0.1 seconds
              • Unit - Move camUnit[p] instantly to ((Position of camUnit[p]) offset by moveAmount towards (camAngle - 180.0) degrees) (Blend)
            • Else

The Initializers
Trigger:
  • InitializeCamTimer
    • Events
      • Timer - Elapsed time is 0.0 Game Time seconds
    • Local Variables
    • Conditions
    • Actions
      • Timer - Start camTimer as a Repeating timer that will expire in 0.0625 Game Time seconds


Trigger:
  • CamTimerExpire
    • Events
      • Timer - camTimer expires
    • Local Variables
    • Conditions
    • Actions
      • updateThirdPersonCamera()
      • updateThirdPersonMovement()


And finally the test Function:
Trigger:
  • TestCam
    • Events
      • Game - Map initialization
    • Local Variables
    • Conditions
    • Actions
      • Variable - Set camUnit[1] = Zealot [40.02, 63.87]
      • setThirdPersonCamera(Zealot [40.02, 63.87], 1)
 

Attachments

  • SpaceBall.SC2Map.zip
    257.9 KB · Views: 205
  • 3PMovementTest.SC2Map.zip
    98.8 KB · Views: 182

Derek0

New Member
Reaction score
1
I could have waited 14 minutes and you would've asked my same question. Brilliant.

I am having the same problem as your second problem. The camera yaw seems to stay at 90.0 no matter which way you move your camera with your mouse. Camera rotation seems to stay at 180.0 regardless of camera mouse movements as well. I don't know if this is a bug in the latest build or if I'm doing something wrong. I'm still trying different things and I'll post if I find something out.
 

PrisonLove

Hard Realist
Reaction score
78
Very strange discovery. The movement system only works in a certain part of the map. It's very odd, but can anyone hypothesize as to why this is happening?
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
I can't seem to have your issue. I'm using just about the same system, though different in some areas. I'm setting camera values, and all work perfectly. Camera rotates, it's at the right settings and everything. So I am confused.
 

Derek0

New Member
Reaction score
1
Well I can't seem to find out the mouse/camera/facing problem, but as for your first problem, try turning on the "Play Forever" option instead of just using "No Options" for your animation trigger. Or did you find another way to fix it?
 

PrisonLove

Hard Realist
Reaction score
78
I figured out the animation problem, thanks. I uploaded the map to the first post so that people can see. It's a bizarre thing. Move the zealot toward the opposite end of the map and after a while you'll see that he begins to not be able to turn around.

EDIT: just uploaded the newest version of the map. In this one it sets the Zealot's facing to the camera yaw everytime the timer expires. The problem is that the unit will only face the camera yaw when it is in the bottom left quadrant of the map. I don't know why this is. Is it bug? Has anyone else experienced this? Is it a mac thing (wouldn't surprise me). Can someone download the map and test it to see if they get this issue as well?
 

PrisonLove

Hard Realist
Reaction score
78
BUMP: I was able to replicate the problem. I uploaded a 3PMovementTest map. In this map I divided it into quadrants using terrain tiles. You'll notice that if you go too far past your starting quadrant (lower left) the marine will stop facing the camera yaw. I tried it on multiple tilesets so it's not an issue with the tileset used. This map is a different size than the one I used for my main map (this one is smaller), so that lead me to determine that after the unit passes a certain x or y value on the coordinate plane, the unit stops adjusting to the yaw, not just when it leaves one quadrant of the map like in the SpaceBall map I have posted. Is this a bug with the editor or with my code?

Help please!
 

Builder Bob

Live free or don't
Reaction score
249
I did a short test with your map to see what the readout of the camera yaw was. For some reason, it's not giving the right output in the areas you are describing. Totally weird...

I haven't done a lot of testing though. Maybe try to see at what x/y coordinates of the map the bug occures. Have you adjusted the size of the map after creating it? At first glance it looks like a bug to me, but maybe it has a natural explanation.

Edit: I have a pc. Not a mac issue
 

PrisonLove

Hard Realist
Reaction score
78
For the 3PMovementTest map I adjusted the size of the map after creating it, but the problem existed both before and after the adjustment. For the SpaceBall map I did not ever adjust the map size after creation.

Thanks for testing, does anyone have a possible solution?

Edit: I was looking around the SC2 beta forums and other people have reported this issue with the latest patch. I suppose it's a bug that needs to be fixed by Blizzard, but if anybody else has a solution I would be glad to hear it.

Here is the link to the discussion: SC2 Beta Site
 

Frozenwind

System maker
Reaction score
99
It might lag, but try resetting the camera every time a movement occurs? Then it can't bug like this at least. Temporary solution until they debugged it. (So I recommend added comment tags so you know what you added as temp. solution).


Or make your map bigger (if possible) and only play in one quadrant of it. Might be a little bit lame though.
 

PrisonLove

Hard Realist
Reaction score
78
Does anyone know if this was fixed in the retail version? Mine is on order so I won't have it for a few days, but I'd like to know.
 

Derek0

New Member
Reaction score
1
It started working on my map at least when I installed the retail version. I'm guessing it's fixed.
 
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