sbox-scenestaging
sbox-scenestaging copied to clipboard
Setting the parent of a gameobject during a collision doesn't maintain position
right now I have some code on a thrown object so that this runs in OnCollisionStart
protected override void OnThrowImpact( Collision collision )
{
if ( !collision.Other.GameObject.TryGetComponent<IDamageable>( out var damageable, true, true ) )
return;
PhysicsComponent.Enabled = false;
ModelCollider.Enabled = false;
GameObject.SetParent( damageable.GameObject );
}
However, it acts like this: throw.webm
If I comment out the SetParent
it behaves much closer to as expected:
throw.webm