fix: auto-detach parented entities on applyImpulse (fixes SDK #32)#18
Open
cryptochris8 wants to merge 1 commit intohytopiagg:mainfrom
Open
fix: auto-detach parented entities on applyImpulse (fixes SDK #32)#18cryptochris8 wants to merge 1 commit intohytopiagg:mainfrom
cryptochris8 wants to merge 1 commit intohytopiagg:mainfrom
Conversation
…gg#32) When applyImpulse, applyImpulseAtPoint, or applyTorqueImpulse is called on a parented entity, automatically detach it from its parent while preserving the current world position and rotation. This enables the common "pick up and throw" pattern where entities are parented to a player and then launched with an impulse. Previously, parented entities had their rigid body type set to KINEMATIC_VELOCITY, causing _requireDynamic() to silently reject impulse calls. The fix detaches and restores the original body type before applying the impulse. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes SDK issue #32 —
applyImpulse()silently failing aftersetParent().When an entity is parented, its rigid body type changes to KINEMATIC_VELOCITY to prevent independent physics. However, this causes
applyImpulse()to silently fail since it requires a DYNAMIC body. This breaks the common "pick up and throw" game pattern.Fix: Overrides
applyImpulse,applyImpulseAtPoint, andapplyTorqueImpulsein Entity.ts to automatically detach from the parent before applying the impulse. The entity's current world position and rotation are preserved during detachment so it doesn't snap to the origin. The body type is restored to DYNAMIC through the existing_lastParentlessTypemechanism.At default (no parent), behavior is completely unchanged — the override just delegates to super.
Test plan
applyImpulse()— entity should detach and flyapplyImpulseAtPoint()andapplyTorqueImpulse()also work on parented entities🤖 Generated with Claude Code