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: 206
  • 3PMovementTest.SC2Map.zip
    98.8 KB · Views: 183

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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top