maint: various clean up, movement tweaks, and smoothing fixes
This commit is contained in:
@@ -78,7 +78,7 @@ public class SettingValue<T> : IResettableSettingValue{
|
||||
currentSmoothing = Mathf.MoveTowards(currentSmoothing, targetSmoothing, targetEasing * targetEasing * Time.deltaTime);
|
||||
|
||||
if (typeof(T) == typeof(float)) {
|
||||
currentValue = (T)(object)Mathf.SmoothDamp((float)(object)currentValue, (float)(object)targetValue, ref refVelFloat, currentSmoothing * currentSmoothing * Time.deltaTime);
|
||||
currentValue = (T)(object)Mathf.SmoothDamp((float)(object)currentValue, (float)(object)targetValue, ref refVelFloat, currentSmoothing * Time.deltaTime);
|
||||
}
|
||||
|
||||
if (typeof(T) == typeof(Vector2)) {
|
||||
@@ -103,5 +103,6 @@ public class SettingValue<T> : IResettableSettingValue{
|
||||
defaultValue = targetValue;
|
||||
defaultSmoothing = targetSmoothing;
|
||||
defaultEasing = targetEasing;
|
||||
currentSmoothing = targetSmoothing;
|
||||
}
|
||||
}
|
||||
@@ -210,14 +210,22 @@ namespace Reset.Units{
|
||||
}
|
||||
}
|
||||
|
||||
public void SetNewDirection(Vector2 value, float relativity, bool absolute, Vector2 relativeTo = default){ // new
|
||||
Vector2 relativeValue = relativeTo + value;
|
||||
public void SetNewDirection(Vector2 value, float relativity, bool absolute, Vector2 relativeTo = default, bool relativeToRotation = true){ // new
|
||||
Vector2 relativeValue;
|
||||
|
||||
if (relativeToRotation){
|
||||
relativeValue = (Quaternion.LookRotation(relativeTo.ToVector3()) * value.ToVector3()).ToVector2();
|
||||
} else {
|
||||
relativeValue = relativeTo + value;
|
||||
}
|
||||
|
||||
if (absolute){
|
||||
resolvedMovement.moveDirection.World = Vector2.Lerp(resolvedMovement.moveDirection.World, relativeValue, relativity);
|
||||
} else {
|
||||
resolvedMovement.moveDirection.World = Vector2.Lerp(resolvedMovement.moveDirection.World, resolvedMovement.moveDirection.World + relativeValue, relativity);
|
||||
}
|
||||
|
||||
Debug.Log(resolvedMovement.moveDirection.World);
|
||||
}
|
||||
|
||||
public void SetNewRawDirection(Vector2 value, float relativity, bool absolute, Vector2 relativeTo = default){ // new
|
||||
@@ -251,6 +259,26 @@ namespace Reset.Units{
|
||||
public void SetSpecifiedRotation(Quaternion inputRotation){
|
||||
specifiedRotation = inputRotation;
|
||||
}
|
||||
|
||||
public Vector2 GetResolvedDirection(){
|
||||
return resolvedMovement.moveDirection.World;
|
||||
}
|
||||
|
||||
public Vector3 GetResolvedDirectionVector3(){
|
||||
return resolvedMovement.moveDirection.World.ToVector3();
|
||||
}
|
||||
|
||||
public float GetResolvedSpeed(){
|
||||
return resolvedMovement.moveSpeed;
|
||||
}
|
||||
|
||||
public float GetResolvedGravity(){
|
||||
return resolvedMovement.gravity;
|
||||
}
|
||||
|
||||
public Quaternion GetResolvedRotation(){
|
||||
return resolvedMovement.rotation;
|
||||
}
|
||||
|
||||
[Button("Initialize Settings", ButtonHeight = 30), PropertySpace(10,5 )]
|
||||
void InitAllSettings(){
|
||||
@@ -289,7 +317,6 @@ namespace Reset.Units{
|
||||
public void OverwriteDirectionFromInput(Vector2 value, float priority, float speed = Mathf.Infinity){ // Old
|
||||
Debug.LogError("Using an old movement command! Switch to one of the new alternatives!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user