gg.easy.airship 0.1.2129 → 0.1.2130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -158,6 +158,8 @@ namespace Code.Player.Character.MovementSystems.Character
|
|
|
158
158
|
private Vector3 lookVector;
|
|
159
159
|
private BinaryBlob customInputData;
|
|
160
160
|
|
|
161
|
+
[SyncVar] public Vector3 startingLookVector;
|
|
162
|
+
|
|
161
163
|
// State information
|
|
162
164
|
public CharacterSnapshotData currentMoveSnapshot = new CharacterSnapshotData() {};
|
|
163
165
|
public CharacterAnimationSyncData currentAnimState = new CharacterAnimationSyncData() {};
|
|
@@ -186,6 +188,16 @@ namespace Code.Player.Character.MovementSystems.Character
|
|
|
186
188
|
_cameraTransform = Camera.main.transform;
|
|
187
189
|
}
|
|
188
190
|
|
|
191
|
+
public override void OnStartClient() {
|
|
192
|
+
base.OnStartClient();
|
|
193
|
+
this.lookVector = this.startingLookVector;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public override void OnStartServer() {
|
|
197
|
+
base.OnStartServer();
|
|
198
|
+
this.lookVector = this.startingLookVector;
|
|
199
|
+
}
|
|
200
|
+
|
|
189
201
|
public override void SetMode(NetworkedStateSystemMode mode)
|
|
190
202
|
{
|
|
191
203
|
Debug.Log("Running movement in " + mode + " mode for " + this.name + ".");
|
|
@@ -845,7 +857,7 @@ namespace Code.Player.Character.MovementSystems.Character
|
|
|
845
857
|
|
|
846
858
|
//Instantly move at the desired speed
|
|
847
859
|
var moveMagnitude = characterMoveVelocity.magnitude;
|
|
848
|
-
var
|
|
860
|
+
var flatVelMagnitude = flatVelocity.magnitude;
|
|
849
861
|
|
|
850
862
|
//Don't move character in direction its already moveing
|
|
851
863
|
//Positive dot means we are already moving in this direction. Negative dot means we are moving opposite of velocity.
|
|
@@ -863,13 +875,13 @@ namespace Code.Player.Character.MovementSystems.Character
|
|
|
863
875
|
newVelocity.z = command.moveDir.z * currentMoveSnapshot.currentSpeed;
|
|
864
876
|
}
|
|
865
877
|
else if (!isImpulsing && !currentMoveSnapshot.airborneFromImpulse && //Not impulsing AND under our max speed
|
|
866
|
-
(
|
|
878
|
+
(flatVelMagnitude < (movementSettings.useAccelerationMovement
|
|
867
879
|
? currentMoveSnapshot.currentSpeed
|
|
868
880
|
: Mathf.Max(movementSettings.sprintSpeed, currentMoveSnapshot.currentSpeed) + 1)))
|
|
869
881
|
{
|
|
870
882
|
if (movementSettings.useAccelerationMovement)
|
|
871
883
|
{
|
|
872
|
-
newVelocity += Vector3.ClampMagnitude(characterMoveVelocity, currentMoveSnapshot.currentSpeed -
|
|
884
|
+
newVelocity += Vector3.ClampMagnitude(characterMoveVelocity, currentMoveSnapshot.currentSpeed - flatVelMagnitude);
|
|
873
885
|
}
|
|
874
886
|
else
|
|
875
887
|
{
|
|
@@ -879,7 +891,7 @@ namespace Code.Player.Character.MovementSystems.Character
|
|
|
879
891
|
// if(Mathf.Abs(characterMoveVelocity.z) > Mathf.Abs(newVelocity.z)){
|
|
880
892
|
// newVelocity.z = characterMoveVelocity.z;
|
|
881
893
|
// }
|
|
882
|
-
if (moveMagnitude + .5f >=
|
|
894
|
+
if (moveMagnitude + .5f >= flatVelMagnitude)
|
|
883
895
|
{
|
|
884
896
|
newVelocity.x = characterMoveVelocity.x;
|
|
885
897
|
newVelocity.z = characterMoveVelocity.z;
|
|
@@ -888,11 +900,30 @@ namespace Code.Player.Character.MovementSystems.Character
|
|
|
888
900
|
}
|
|
889
901
|
else
|
|
890
902
|
{
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
903
|
+
if(this.movementSettings.useAccelerationMovement){
|
|
904
|
+
//Using acceleration movement
|
|
905
|
+
newVelocity += normalizedMoveDir * (dirDot * dirDot / 2) *
|
|
906
|
+
(groundedState == CharacterState.Sprinting
|
|
907
|
+
? this.movementSettings.sprintAccelerationForce
|
|
908
|
+
: movementSettings.accelerationForce);
|
|
909
|
+
}else{
|
|
910
|
+
//Impulsing
|
|
911
|
+
var forwardMod = Mathf.Max(0, dirDot);
|
|
912
|
+
var addedForce = groundedState == CharacterState.Sprinting
|
|
913
|
+
? this.movementSettings.sprintAccelerationForce
|
|
914
|
+
: movementSettings.accelerationForce;
|
|
915
|
+
if(flatVelMagnitude+addedForce < currentMoveSnapshot.currentSpeed){
|
|
916
|
+
forwardMod = 1;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
//Apply the force
|
|
920
|
+
newVelocity += normalizedMoveDir * forwardMod * addedForce;
|
|
921
|
+
|
|
922
|
+
//Never get faster than you've been impulsed
|
|
923
|
+
var flatVel = Vector3.ClampMagnitude(new Vector3(newVelocity.x, 0, newVelocity.z), Mathf.Max(addedForce, flatVelMagnitude));
|
|
924
|
+
newVelocity.x = flatVel.x;
|
|
925
|
+
newVelocity.z = flatVel.z;
|
|
926
|
+
}
|
|
896
927
|
}
|
|
897
928
|
|
|
898
929
|
//print("isreplay: " + replaying + " didHitForward: " + didHitForward + " moveVec: " + characterMoveVector + " colliderDot: " + colliderDot + " for: " + forwardHit.collider?.gameObject.name + " point: " + forwardHit.point);
|