sbox-scenestaging icon indicating copy to clipboard operation
sbox-scenestaging copied to clipboard

Setting the parent of a gameobject during a collision doesn't maintain position

Open Fortune117 opened this issue 1 year ago • 0 comments

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

Fortune117 avatar Nov 15 '23 06:11 Fortune117