Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Add support for joints and motors #143

Open
AyeGill opened this issue Aug 26, 2021 · 1 comment
Open

Add support for joints and motors #143

AyeGill opened this issue Aug 26, 2021 · 1 comment
Labels
enhancement New feature or improvement

Comments

@AyeGill
Copy link

AyeGill commented Aug 26, 2021

Well, the title explains it: it would be nice to support joints and motors.

bevy_rapier implements these as separate entities. For example, one does:

let joint = BallJoint::new(Vec3::new(0.0, 0.0, 1.0).into(), Vec3::new(0.0, 0.0, -3.0).into());
commands.spawn().insert(JointBuilderComponent::new(joint, entity1, entity2));

This seems like the most reasonable way of doing things. It is

My suggestion would be to have something like a "Joint" struct, containing the data necessary to construct a joint, including two entities. Then the "Joint system" could go over all the changed joint components each step, creating/modifying/deleting joints from the JointSet as needed. The motor configuration could either be a separate component or an optional part of the joint component (the advantage of doing it the second way is that the type of a motor configuration depends on the joint type - so this allows us to prevent people from adding incompatible motor and joints to the same entity).

I'm imagining using this something like

commands.spawn().insert(Joint::Ball(entity_1, entity_2, Vec3::new(1.0,0.0,0.0), Vec3::new(-1.0,0.0,0.0)))

I'm happy to take a crack at implementing this myself if this sounds like a reasonable solution.

@jcornaz
Copy link
Owner

jcornaz commented Aug 26, 2021

Sounds good to me. Thanks for the suggestion and for taking a look at it :-)

@jcornaz jcornaz added the up-for-grabs Good for newcomers label Aug 26, 2021
@jcornaz jcornaz added the enhancement New feature or improvement label Aug 26, 2021
@jcornaz jcornaz removed the up-for-grabs Good for newcomers label May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants