gg.easy.airship 0.1.1821 → 0.1.1822
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
using
|
|
1
|
+
using UnityEditor.EditorTools;
|
|
2
|
+
using UnityEngine;
|
|
2
3
|
using UnityEngine.Serialization;
|
|
3
4
|
|
|
4
5
|
namespace Code.Player.Character.API {
|
|
@@ -28,6 +29,9 @@ namespace Code.Player.Character.API {
|
|
|
28
29
|
public float accelerationForce = 1;
|
|
29
30
|
[Tooltip("How much to accelerate sprinting (units per second) when using acceleration movement or when going faster than the target speed")] [Min(0f)]
|
|
30
31
|
public float sprintAccelerationForce = 1.4f;
|
|
32
|
+
[Tooltip("If accelerating in a direction you are already moving, how much force can you still apply?")]
|
|
33
|
+
[Range(0,1)]
|
|
34
|
+
public float minAccelerationDelta = 0;
|
|
31
35
|
|
|
32
36
|
[Tooltip("Only allow sprinting forward.")]
|
|
33
37
|
public bool onlySprintForward = false;
|
|
@@ -40,6 +40,7 @@ namespace Code.Player.Character {
|
|
|
40
40
|
private Vector2 targetVelNormalized;
|
|
41
41
|
private float verticalVel = 0;
|
|
42
42
|
private float currentPlaybackSpeed = 0;
|
|
43
|
+
private float currentSpeed = 0;
|
|
43
44
|
private bool firstPerson = false;
|
|
44
45
|
private float lastStateTime = 0;
|
|
45
46
|
private float targetPlaybackSpeed = 0;
|
|
@@ -131,9 +132,9 @@ namespace Code.Player.Character {
|
|
|
131
132
|
//Blend directional influence
|
|
132
133
|
float blendMod = targetMagnitude > currentMagnitude ? this.directionalBlendLerpMod : this.directionalBlendLerpMod /2f;
|
|
133
134
|
currentVelNormalized = Vector2.MoveTowards(currentVelNormalized, targetVelNormalized, blendMod * Time.deltaTime);
|
|
134
|
-
animator.SetFloat("VelX",
|
|
135
|
+
animator.SetFloat("VelX", currentSpeed < .01 ? 0 : currentVelNormalized.x);// * Mathf.Clamp01(currentPlaybackSpeed));
|
|
135
136
|
animator.SetFloat("VelY", Mathf.Lerp(animator.GetFloat("VelY"), verticalVel, Time.deltaTime*1.5f));
|
|
136
|
-
animator.SetFloat("VelZ",
|
|
137
|
+
animator.SetFloat("VelZ", currentSpeed < .01 ? 0 : currentVelNormalized.y);// * Mathf.Clamp01(currentPlaybackSpeed));
|
|
137
138
|
animator.SetFloat("Speed", targetMagnitude);
|
|
138
139
|
|
|
139
140
|
|
|
@@ -166,7 +167,7 @@ namespace Code.Player.Character {
|
|
|
166
167
|
} else if (currentState == CharacterState.Crouching) {
|
|
167
168
|
targetSpeed = 2.1233335f;
|
|
168
169
|
}
|
|
169
|
-
|
|
170
|
+
currentSpeed = new Vector2(localVel.x, localVel.z).magnitude;
|
|
170
171
|
//print("currentSpeed: " + currentSpeed + " targetSpeed: " + targetSpeed + " playbackSpeed: " + targetPlaybackSpeed);
|
|
171
172
|
this.targetPlaybackSpeed = Mathf.Max(0, currentSpeed / targetSpeed);
|
|
172
173
|
targetVelNormalized = new Vector2(localVel.x, localVel.z).normalized;
|
|
@@ -287,7 +287,6 @@ private void OnEnable() {
|
|
|
287
287
|
if (grounded && !prevGrounded) {
|
|
288
288
|
jumpCount = 0;
|
|
289
289
|
timeSinceBecameGrounded = 0f;
|
|
290
|
-
airborneFromImpulse = false;
|
|
291
290
|
this.OnImpactWithGround?.Invoke(currentVelocity);
|
|
292
291
|
} else {
|
|
293
292
|
timeSinceBecameGrounded = Math.Min(timeSinceBecameGrounded + deltaTime, 100f);
|
|
@@ -561,7 +560,7 @@ private void OnEnable() {
|
|
|
561
560
|
//Apply the impulse to the velocity
|
|
562
561
|
newVelocity += impulseVelocity;
|
|
563
562
|
impulseVelocity = Vector3.zero;
|
|
564
|
-
airborneFromImpulse =
|
|
563
|
+
airborneFromImpulse = !grounded || impulseVelocity.y > .01f;
|
|
565
564
|
}
|
|
566
565
|
#endregion
|
|
567
566
|
|
|
@@ -679,9 +678,9 @@ private void OnEnable() {
|
|
|
679
678
|
|
|
680
679
|
//Don't move character in direction its already moveing
|
|
681
680
|
//Positive dot means we are already moving in this direction. Negative dot means we are moving opposite of velocity.
|
|
682
|
-
//
|
|
681
|
+
//Multipy by 2 so perpendicular movement is still fully applied rather than half applied
|
|
683
682
|
var rawDot = Vector3.Dot(flatVelocity.normalized, normalizedMoveDir);
|
|
684
|
-
var dirDot = Mathf.Clamp01(1-rawDot);
|
|
683
|
+
var dirDot = Mathf.Max(moveData.minAccelerationDelta, Mathf.Clamp01((1-rawDot)*2));
|
|
685
684
|
|
|
686
685
|
if(useExtraLogging){
|
|
687
686
|
print("old vel: " + currentVelocity + " new vel: " + newVelocity + " move dir: " + characterMoveVelocity + " Dir dot: " + dirDot + " currentSpeed: " + currentSpeed + " grounded: " + grounded + " canJump: " + canJump + " didJump: " + didJump);
|
|
@@ -690,8 +689,7 @@ private void OnEnable() {
|
|
|
690
689
|
if (inAir){
|
|
691
690
|
//clampedIncrease *= moveData.airSpeedMultiplier;
|
|
692
691
|
}
|
|
693
|
-
|
|
694
|
-
if(_flying || (velMagnitude < (moveData.useAccelerationMovement?currentSpeed:Mathf.Max(moveData.sprintSpeed, currentSpeed) + 1) && !isImpulsing)){
|
|
692
|
+
if(!isImpulsing && !airborneFromImpulse && _flying || (velMagnitude < (moveData.useAccelerationMovement?currentSpeed:Mathf.Max(moveData.sprintSpeed, currentSpeed) + 1))){
|
|
695
693
|
// if(clampedIncrease.x < 0){
|
|
696
694
|
// clampedIncrease.x = Mathf.Max(clampedIncrease.x, newVelocity.x + clampedIncrease.x);
|
|
697
695
|
// }else{
|
|
@@ -702,7 +700,6 @@ private void OnEnable() {
|
|
|
702
700
|
// }else{
|
|
703
701
|
// clampedIncrease.z = Mathf.Min(clampedIncrease.z, newVelocity.z + clampedIncrease.z);
|
|
704
702
|
// }
|
|
705
|
-
|
|
706
703
|
if(moveData.useAccelerationMovement){
|
|
707
704
|
newVelocity += characterMoveVelocity;
|
|
708
705
|
}else{
|
|
@@ -769,8 +766,10 @@ private void OnEnable() {
|
|
|
769
766
|
var canStopVel = !airborneFromImpulse && (!inAir || moveData.useMinimumVelocityInAir) && !isImpulsing;
|
|
770
767
|
var notTryingToMove = normalizedMoveDir.sqrMagnitude < .1f;
|
|
771
768
|
var underMin = physics.GetFlatDistance(Vector3.zero, newVelocity) <= moveData.minimumVelocity;
|
|
769
|
+
//print("airborneFromImpulse: " + airborneFromImpulse + " unerMin: " +underMin + " notTryingToMove: " + notTryingToMove);
|
|
772
770
|
if(canStopVel && notTryingToMove && underMin){
|
|
773
771
|
//Not intending to move so snap to zero (Fake Dynamic Friction)
|
|
772
|
+
//print("STOPPING VELOCITY");
|
|
774
773
|
newVelocity.x = 0;
|
|
775
774
|
newVelocity.z = 0;
|
|
776
775
|
}
|