Add Kinematic Colliders#460
Merged
Merged
Conversation
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.
This PR adds support for kinematic colliders. It closes #322.
The behavior is quite similar to Unity's kinematic rigidbody, i.e. it's not part of the simulation, but can transform freely with the colliders being transformed along.
vpe-dynamic-collisions.mp4
How it works
We use the items' transformation matrix as a source. That means a component that transforms an item must go through the VPE-specific data in order to apply the transformation. That also means that just transforming it through Unity's
Transformwon't automatically update the colliders.The rest is automatic. For example, if your component moves an object each frame by changing the primitive's X-position, the physics engine now automatically updates the colliders on each frame.
Caveats
It would be great if the physics engine supported parenting, i.e. transforming a parent object whose children are items that would then be automatically updated. VPX doesn't support this, but here it would make a lot of sense.
It would also be great if moving colliders came with a velocity. Right now, kinematic colliders cannot be used for continuous contact like a ball in a rotating gun, since the gun colliders don't push the ball away when they collide with it (they are literally teleported from position
nton+1each frame).Both of these caveats will eventually be addressed, but aren't part of this PR.
Implementation
The approach is the following:
NativeColliderscollection, calledKinematicColliders.KinematicCollidersAtIdentity).KinematicCollidersAtIdentityas a base, written toKinematicColliders.KinematicCollidersCollisionEventData.IsKinematicTODO before merging
[ ] Treat the remaining item types[ ] Create a new component that applies transformations based on coil signals.[ ] DocumentationThis PR and various comments on Discord made me realize that the next step before getting support for all items is to properly handle parenting. For example, all dragpoint-based items (rubbers, walls, ramps, etc) currently don't transform at all in VPX. They are uniquely defined by their dragpoint's (global) position. The first step would be to make all items transformable, i.e. make their colliders transformable. Once that's possible, the next step is parenting, and then we get kinematic support for all of these items basically for free.