2D World Wrapping with bevy_xpbd #11567
Unanswered
JarredEagley
asked this question in
Q&A
Replies: 1 comment
-
@JarredEagley did you ever manage to find a solution you were satisfied with? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone!
I'm working on a little 2d sidescroller using Bevy and bevy_xpbd physics. It's been a fantastic learning experience! Having worked on game engines before, I'm very impressed with Bevy.
However, I've run into a problem that has left me stumped and some outside input seems warranted.
The gameworld uses cylindrical coordinates. That is to say: The sides wrap around. Think Starbound if you need an example.
Visually doing this is a cakewalk. But handling rigidbodies on the wraparound seam is another story however- especially if you consider constraints.
My current working solution uses a technique similar to Portal:
When an entity passes through the world wraparound bounds, a kinematic ghost rigidbody is spawned on the other side of the world. The ghost rigidbody's position, orientation, and velocities are all mirrored from its real counterpart, and forces applied to the ghost entity are likewise mirrored over to the real entity.
The con: Handling constraints becomes a complete nightmare.
My partner on the project bounced some ideas surrounding simulating rigidbody physics in some form of local reference frame, then mapping the objects back into cylindrical space.
This sounds like it would be a lot more stable, but I'm not sure how such a thing would be accomplished in XPBD without seriously diving into the sourcecode of the physics engine.
I also considered perhaps ghosting entire constrained systems, rather than individual entities. This sounds prone to breaking and not well suited for an ECS architecture, but might be worth a try.
Hopefully this wasn't too rambly. Does anyone have any pointers here?
Beta Was this translation helpful? Give feedback.
All reactions