calculate velocity relative to the reference on anglers

This commit is contained in:
JohnCorby 2022-07-11 10:02:06 -07:00
parent c7b221a840
commit 728efc69df
2 changed files with 5 additions and 3 deletions

View File

@ -28,7 +28,9 @@ public class QSBAngler : LinkedWorldObject<AnglerfishController, AnglerTransform
return; return;
} }
TargetVelocity = (TargetTransform.position - _lastTargetPosition) / Time.fixedDeltaTime; var reference = Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().transform;
_lastTargetPosition = TargetTransform.position; var currentRelPosition = reference.InverseTransformPoint(TargetTransform.position);
TargetVelocity = (currentRelPosition - _lastTargetPosition) / Time.fixedDeltaTime;
_lastTargetPosition = currentRelPosition;
} }
} }

View File

@ -13,6 +13,6 @@ public class RemotePlayerVelocity : MonoBehaviour
var reference = Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().transform; var reference = Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().transform;
var currentRelPosition = reference.InverseTransformPoint(transform.position); var currentRelPosition = reference.InverseTransformPoint(transform.position);
Velocity = (currentRelPosition - _prevRelPosition) / Time.fixedDeltaTime; Velocity = (currentRelPosition - _prevRelPosition) / Time.fixedDeltaTime;
_prevRelPosition = reference.InverseTransformPoint(transform.position); _prevRelPosition = currentRelPosition;
} }
} }