OfflineRigidbody conflicting with Prediction (duh, but read) #670
Replies: 3 comments
-
Yeah, I'm having the same problem! |
Beta Was this translation helpful? Give feedback.
-
Can you see if this helps... public void UpdateRigidbodies(Transform t, RigidbodyType rbType, bool getInChildren)
{
_rigidbodyType = rbType;
_getInChildren = getInChildren;
_rigidbodyDatas.Clear();
_rigidbody2dDatas.Clear();
//3D.
if (rbType == RigidbodyType.Rigidbody)
{
if (getInChildren)
{
Rigidbody[] rbs = t.GetComponentsInChildren<Rigidbody>();
for (int i = 0; i < rbs.Length; i++)
AddRigidbody(rbs[i]);
}
else
{
Rigidbody rb = t.GetComponent<Rigidbody>();
if (rb != null)
AddRigidbody(rb);
}
}
//2D.
else
{
if (getInChildren)
{
Rigidbody2D[] rbs = t.GetComponentsInChildren<Rigidbody2D>();
for (int i = 0; i < rbs.Length; i++)
AddRigidbody2D(rbs[i]);
}
else
{
Rigidbody2D rb = t.GetComponent<Rigidbody2D>();
if (rb != null)
AddRigidbody2D(rb);
}
}
void AddRigidbody(Rigidbody rb)
{
if (!rb.TryGetComponent<OfflineRigidbody>(out _))
_rigidbodyDatas.Add(new(rb));
}
void AddRigidbody2D(Rigidbody2D rb)
{
if (!rb.TryGetComponent<OfflineRigidbody>(out _))
_rigidbody2dDatas.Add(new(rb));
}
_initialized = true;
} |
Beta Was this translation helpful? Give feedback.
-
I won't be able to properly test this, I applogize. I took prediction out of my characters a few months back, and the original issue was very difficult to pinpoint and reliably trigger. The code that led to it is gone somewhere and I don't remember how to reproduce the issue if I went and found the code anyway. I can say that I solved the issue originally by adding the 'getInChildren' bool to the base prediction rigidbody somewhere so it was not trying to touch the ragdoll parts inside the character. |
Beta Was this translation helpful? Give feedback.
-
I don't think this is a bug, but there should be some kind of warning when attempting to do this. I don't think this needs to be an accommodated feature either, I just think there should be an error message at least.
I have a physics-based rigidbody character controller. It has a rigidbody and colliders. Underneath that top-level character gameobject is the actual character rigging and all it's limbs, upon many of which are rigidbodies to create a ragdoll. Under certain conditions I make the ragdoll drop, how I do this is irrelevant - these limbs are not using prediction. I have an offlinerigidbody on them so that they simulate properly. This was my DOOM. Both Prediction on the top-level gameobject and offlinerigidbody are trying to do the same pause/unpause - a process that normally "preserves" the current actual rigidbody state, but they were overstepping each other and the "default" state for the ragdoll get set to be the Paused state. This is very obvious in hindsight and is easy to track and the signs were there, but it did not behave quite as consistently as it would seem it should've so this issue was very difficult for me to hunt down.
Version: 4.2.2
Beta Was this translation helpful? Give feedback.
All reactions