diff --git a/Engine.Core/Transform.cs b/Engine.Core/Transform.cs index 394c788..fff0636 100644 --- a/Engine.Core/Transform.cs +++ b/Engine.Core/Transform.cs @@ -127,13 +127,13 @@ public class Transform : ITransform return; ITransform? previousParent = Parent; - if (Parent is not null) + if (previousParent is not null) { - Parent.RemoveChild(this); - Parent.OnPositionChanged -= RecalculatePosition; - Parent.OnScaleChanged -= RecalculateScale; - Parent.OnRotationChanged -= RecalculateRotation; - Parent.OnParentChanged -= NotifyChildrenOnParentChange; + previousParent.RemoveChild(this); + previousParent.OnPositionChanged -= RecalculatePosition; + previousParent.OnScaleChanged -= RecalculateScale; + previousParent.OnRotationChanged -= RecalculateRotation; + previousParent.OnParentChanged -= NotifyChildrenOnParentChange; } Parent = transform;