mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-05 06:39:50 +00:00
back to using custom SetVelocity
This commit is contained in:
parent
57ba9e1d1b
commit
333f23d797
@ -73,7 +73,7 @@ namespace QSB.ShipSync.TransformSync
|
||||
var targetVelocity = ReferenceTransform.GetAttachedOWRigidbody().GetPointVelocity(targetPos) + _relativeVelocity;
|
||||
var targetAngularVelocity = ReferenceTransform.GetAttachedOWRigidbody().GetAngularVelocity() + _relativeAngularVelocity;
|
||||
|
||||
(AttachedObject as OWRigidbody).SetVelocity(targetVelocity);
|
||||
SetVelocity(AttachedObject as OWRigidbody, targetVelocity);
|
||||
(AttachedObject as OWRigidbody).SetAngularVelocity(targetAngularVelocity);
|
||||
|
||||
return true;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using QSB.Utility;
|
||||
using QuantumUNET.Transport;
|
||||
using UnityEngine;
|
||||
@ -163,7 +164,7 @@ namespace QSB.Syncs.Sectored.Rigidbodies
|
||||
var targetVelocity = ReferenceTransform.GetAttachedOWRigidbody().GetPointVelocity(targetPos) + _relativeVelocity;
|
||||
var targetAngularVelocity = ReferenceTransform.GetAttachedOWRigidbody().GetAngularVelocity() + _relativeAngularVelocity;
|
||||
|
||||
(AttachedObject as OWRigidbody).SetVelocity(targetVelocity);
|
||||
SetVelocity(AttachedObject as OWRigidbody, targetVelocity);
|
||||
(AttachedObject as OWRigidbody).SetAngularVelocity(targetAngularVelocity);
|
||||
|
||||
return true;
|
||||
@ -218,6 +219,26 @@ namespace QSB.Syncs.Sectored.Rigidbodies
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void SetVelocity(OWRigidbody rigidbody, Vector3 relativeVelocity)
|
||||
{
|
||||
var isRunningKinematic = rigidbody.RunningKinematicSimulation();
|
||||
var currentVelocity = rigidbody.GetValue<Vector3>("_currentVelocity");
|
||||
|
||||
if (isRunningKinematic)
|
||||
{
|
||||
var kinematicRigidbody = rigidbody.GetValue<KinematicRigidbody>("_kinematicRigidbody");
|
||||
kinematicRigidbody.velocity = relativeVelocity + Locator.GetCenterOfTheUniverse().GetStaticFrameVelocity_Internal();
|
||||
}
|
||||
else
|
||||
{
|
||||
var normalRigidbody = rigidbody.GetValue<Rigidbody>("_rigidbody");
|
||||
normalRigidbody.velocity = relativeVelocity + Locator.GetCenterOfTheUniverse().GetStaticFrameVelocity_Internal();
|
||||
}
|
||||
|
||||
rigidbody.SetValue("_lastVelocity", currentVelocity);
|
||||
rigidbody.SetValue("_currentVelocity", relativeVelocity);
|
||||
}
|
||||
|
||||
public float GetVelocityChangeMagnitude()
|
||||
=> (_relativeVelocity - _prevVelocity).magnitude;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using QSB.Utility;
|
||||
using QuantumUNET.Transport;
|
||||
using UnityEngine;
|
||||
@ -154,7 +155,7 @@ namespace QSB.Syncs.Unsectored.Rigidbodies
|
||||
var targetVelocity = ReferenceTransform.GetAttachedOWRigidbody().GetPointVelocity(targetPos) + _relativeVelocity;
|
||||
var targetAngularVelocity = ReferenceTransform.GetAttachedOWRigidbody().GetAngularVelocity() + _relativeAngularVelocity;
|
||||
|
||||
(AttachedObject as OWRigidbody).SetVelocity(targetVelocity);
|
||||
SetVelocity(AttachedObject as OWRigidbody, targetVelocity);
|
||||
(AttachedObject as OWRigidbody).SetAngularVelocity(targetAngularVelocity);
|
||||
|
||||
return true;
|
||||
@ -209,6 +210,26 @@ namespace QSB.Syncs.Unsectored.Rigidbodies
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void SetVelocity(OWRigidbody rigidbody, Vector3 relativeVelocity)
|
||||
{
|
||||
var isRunningKinematic = rigidbody.RunningKinematicSimulation();
|
||||
var currentVelocity = rigidbody.GetValue<Vector3>("_currentVelocity");
|
||||
|
||||
if (isRunningKinematic)
|
||||
{
|
||||
var kinematicRigidbody = rigidbody.GetValue<KinematicRigidbody>("_kinematicRigidbody");
|
||||
kinematicRigidbody.velocity = relativeVelocity + Locator.GetCenterOfTheUniverse().GetStaticFrameVelocity_Internal();
|
||||
}
|
||||
else
|
||||
{
|
||||
var normalRigidbody = rigidbody.GetValue<Rigidbody>("_rigidbody");
|
||||
normalRigidbody.velocity = relativeVelocity + Locator.GetCenterOfTheUniverse().GetStaticFrameVelocity_Internal();
|
||||
}
|
||||
|
||||
rigidbody.SetValue("_lastVelocity", currentVelocity);
|
||||
rigidbody.SetValue("_currentVelocity", relativeVelocity);
|
||||
}
|
||||
|
||||
public float GetVelocityChangeMagnitude()
|
||||
=> (_relativeVelocity - _prevVelocity).magnitude;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user