mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 00:32:43 +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()
|
||||
{
|
||||
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;
|
||||
|
||||
var targetRot = ReferenceTransform.FromRelRot(transform.rotation);
|
||||
|
||||
var onRaft = false;
|
||||
var localPos = Vector3.zero;
|
||||
var localRot = Quaternion.identity;
|
||||
if (Locator.GetPlayerController().GetGroundBody() == AttachedRigidbody)
|
||||
if (Time.unscaledTime >= _lastSetPositionTime + ForcePositionAfterTime)
|
||||
{
|
||||
onRaft = true;
|
||||
localPos = AttachedRigidbody.transform.InverseTransformPoint(Locator.GetPlayerTransform().position);
|
||||
localRot = AttachedRigidbody.transform.InverseTransformRotation(Locator.GetPlayerTransform().rotation);
|
||||
}
|
||||
_lastSetPositionTime = Time.unscaledTime;
|
||||
|
||||
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.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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user