-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: body stickToPlatform doesn't play nice with setParent #628
Comments
Couldn't body watch an onParentChanged event? worldPos is more expensive than pos, no? |
could certainly try that. the setParent code is way newer than the body stickToPlatform code so it's not surprising that the stickToPlatform code wasn't written with the parent being changed in mind. |
The stickToPlatform code is a bit of a hack |
Since you are following the platform's movement, it would make more sense to make the platform the new parent of the player, as you are basically changing the frame of reference. But I guess that would break existing things. |
The player is not standing on the platform. The object that the player picked up (and is now a child of the player) is the platform, and the thing that was sitting on that got flung into the void. |
Yes, but if the thing on the platform was a child of the platform, it wouldn't be affected by the player picking up the platform, it would still be relative to the platform. Now we have some hack which tries to map the motion of the platform to the things on the platform, while the thing on the platform should just have been parented. But when stickToPlatform was written, you couldn't change the parent. |
This could also be fixed by having |
That would still be a hack though. |
i think i just found a new weird bug with the way that the
curPlatform
interacts with thesetParent
function. In my game there can be objects stacked on top of each other, and when the player grabs the bottom one it is made a child of the player, and so the pos is set to (0, 0), but it is relative to the player. So the thing that was sitting on top of the player, thinks that the platform teleported to (0, 0) and moves to match, except the thing that was sitting on top isn't relative to the player, and flies off into the void. ofc I could fix this by using{stickToPlatform: false}
but I need the stick to platform functionality.the best fix might just be to use
.worldPos()!
in the delta computations instead of.pos
in BodyComp.update(), but I haven't tested this yet.The text was updated successfully, but these errors were encountered: