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:
Function setThirdPersonCamera
Function updateThirdPersonCamera
Function removeThirdPersonCamera
For Movement:
**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
The Initializers
And finally the test Function:
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
- Actions
- Player Group - Pick each player in camPlayerGroup and do (Actions)
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 <Integer>
- camAngle = 0.0 <Real>
- moveAmount = 0.0 <Real>
- 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
- Conditions
- Or
- 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
- If
- Else
- If
- 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
- If
- 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
- If
- 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
- If
- 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
- If
- 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
- If
- 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
- If
- 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
- If
- Actions
- Player Group - Pick each player in camPlayerGroup and do (Actions)
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
- Events
Trigger:
- CamTimerExpire
- Events
- Timer - camTimer expires
- Local Variables
- Conditions
- Actions
- updateThirdPersonCamera()
- updateThirdPersonMovement()
- Events
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)
- Events