mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-06 00:39:55 +00:00
if not on raft, set pos/rot every interval
This commit is contained in:
parent
88e17b47e3
commit
7c45e2427b
@ -75,32 +75,29 @@ public class RaftTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehaviou
|
|||||||
protected override void ApplyToAttached()
|
protected override void ApplyToAttached()
|
||||||
{
|
{
|
||||||
var targetPos = ReferenceTransform.FromRelPos(transform.position);
|
var targetPos = ReferenceTransform.FromRelPos(transform.position);
|
||||||
|
var targetRot = ReferenceTransform.FromRelRot(transform.rotation);
|
||||||
|
|
||||||
if (Time.unscaledTime >= _lastSetPositionTime + ForcePositionAfterTime)
|
var onRaft = Locator.GetPlayerController().GetGroundBody() == AttachedRigidbody;
|
||||||
|
if (onRaft)
|
||||||
{
|
{
|
||||||
_lastSetPositionTime = Time.unscaledTime;
|
if (Time.unscaledTime >= _lastSetPositionTime + ForcePositionAfterTime)
|
||||||
|
|
||||||
var targetRot = ReferenceTransform.FromRelRot(transform.rotation);
|
|
||||||
|
|
||||||
var onRaft = false;
|
|
||||||
var localPos = Vector3.zero;
|
|
||||||
var localRot = Quaternion.identity;
|
|
||||||
if (Locator.GetPlayerController().GetGroundBody() == AttachedRigidbody)
|
|
||||||
{
|
{
|
||||||
onRaft = true;
|
_lastSetPositionTime = Time.unscaledTime;
|
||||||
localPos = AttachedRigidbody.transform.InverseTransformPoint(Locator.GetPlayerTransform().position);
|
|
||||||
localRot = AttachedRigidbody.transform.InverseTransformRotation(Locator.GetPlayerTransform().rotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
var relPos = AttachedRigidbody.transform.ToRelPos(Locator.GetPlayerTransform().position);
|
||||||
|
var relRot = AttachedRigidbody.transform.ToRelRot(Locator.GetPlayerTransform().rotation);
|
||||||
|
|
||||||
|
AttachedRigidbody.SetPosition(targetPos);
|
||||||
|
AttachedRigidbody.SetRotation(targetRot);
|
||||||
|
|
||||||
|
Locator.GetPlayerTransform().position = AttachedRigidbody.transform.FromRelPos(relPos);
|
||||||
|
Locator.GetPlayerTransform().rotation = AttachedRigidbody.transform.FromRelRot(relRot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
AttachedRigidbody.SetPosition(targetPos);
|
AttachedRigidbody.SetPosition(targetPos);
|
||||||
AttachedRigidbody.SetRotation(targetRot);
|
AttachedRigidbody.SetRotation(targetRot);
|
||||||
|
|
||||||
if (onRaft)
|
|
||||||
{
|
|
||||||
var playerTransform = Locator.GetPlayerBody().transform;
|
|
||||||
playerTransform.position = AttachedRigidbody.transform.TransformPoint(localPos);
|
|
||||||
playerTransform.rotation = AttachedRigidbody.transform.TransformRotation(localRot);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetVelocity = ReferenceRigidbody.FromRelVel(Velocity, targetPos);
|
var targetVelocity = ReferenceRigidbody.FromRelVel(Velocity, targetPos);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user