mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-10 16:14:45 +00:00
if not in ship, set pos/rot every interval ( + use AttachedTransform instead of AttachedRigidbody.transform)
This commit is contained in:
parent
7c45e2427b
commit
9241614f03
@ -84,14 +84,14 @@ public class RaftTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehaviou
|
||||
{
|
||||
_lastSetPositionTime = Time.unscaledTime;
|
||||
|
||||
var relPos = AttachedRigidbody.transform.ToRelPos(Locator.GetPlayerTransform().position);
|
||||
var relRot = AttachedRigidbody.transform.ToRelRot(Locator.GetPlayerTransform().rotation);
|
||||
var relPos = AttachedTransform.ToRelPos(Locator.GetPlayerTransform().position);
|
||||
var relRot = AttachedTransform.ToRelRot(Locator.GetPlayerTransform().rotation);
|
||||
|
||||
AttachedRigidbody.SetPosition(targetPos);
|
||||
AttachedRigidbody.SetRotation(targetRot);
|
||||
|
||||
Locator.GetPlayerTransform().position = AttachedRigidbody.transform.FromRelPos(relPos);
|
||||
Locator.GetPlayerTransform().rotation = AttachedRigidbody.transform.FromRelRot(relRot);
|
||||
Locator.GetPlayerTransform().position = AttachedTransform.FromRelPos(relPos);
|
||||
Locator.GetPlayerTransform().rotation = AttachedTransform.FromRelRot(relRot);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -57,13 +57,20 @@ public class ShipTransformSync : SectoredRigidbodySync
|
||||
}
|
||||
|
||||
var targetPos = ReferenceTransform.FromRelPos(transform.position);
|
||||
var targetRot = ReferenceTransform.FromRelRot(transform.rotation);
|
||||
|
||||
if (Time.unscaledTime >= _lastSetPositionTime + ForcePositionAfterTime)
|
||||
if (PlayerState.IsInsideShip())
|
||||
{
|
||||
_lastSetPositionTime = Time.unscaledTime;
|
||||
|
||||
var targetRot = ReferenceTransform.FromRelRot(transform.rotation);
|
||||
if (Time.unscaledTime >= _lastSetPositionTime + ForcePositionAfterTime)
|
||||
{
|
||||
_lastSetPositionTime = Time.unscaledTime;
|
||||
|
||||
AttachedRigidbody.SetPosition(targetPos);
|
||||
AttachedRigidbody.SetRotation(targetRot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AttachedRigidbody.SetPosition(targetPos);
|
||||
AttachedRigidbody.SetRotation(targetRot);
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ public class OccasionalTransformSync : UnsectoredRigidbodySync
|
||||
_toMove.Add(new MoveData
|
||||
{
|
||||
Child = child,
|
||||
RelPos = AttachedRigidbody.transform.ToRelPos(pos),
|
||||
RelRot = AttachedRigidbody.transform.ToRelRot(child.GetRotation()),
|
||||
RelPos = AttachedTransform.ToRelPos(pos),
|
||||
RelRot = AttachedTransform.ToRelRot(child.GetRotation()),
|
||||
RelVel = AttachedRigidbody.ToRelVel(child.GetVelocity(), pos),
|
||||
RelAngVel = AttachedRigidbody.ToRelAngVel(child.GetAngularVelocity())
|
||||
});
|
||||
@ -116,9 +116,9 @@ public class OccasionalTransformSync : UnsectoredRigidbodySync
|
||||
{
|
||||
foreach (var data in _toMove)
|
||||
{
|
||||
var pos = AttachedRigidbody.transform.FromRelPos(data.RelPos);
|
||||
var pos = AttachedTransform.FromRelPos(data.RelPos);
|
||||
data.Child.SetPosition(pos);
|
||||
data.Child.SetRotation(AttachedRigidbody.transform.FromRelRot(data.RelRot));
|
||||
data.Child.SetRotation(AttachedTransform.FromRelRot(data.RelRot));
|
||||
data.Child.SetVelocity(AttachedRigidbody.FromRelVel(data.RelVel, pos));
|
||||
data.Child.SetAngularVelocity(AttachedRigidbody.FromRelAngVel(data.RelAngVel));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user