bevy_xpbd
bevy_xpbd copied to clipboard
Add optional `rotation_offset` to FixedJoint
trafficstars
Objective
FixedJoints currently apply entity1's Rotation to entity2.
This change allows you set a fixed rotation offset to entity2's Rotation, relative to entity1.
Here's the output difference in the fixed_joint_2d.rs example, if you make this change:
- commands.spawn(FixedJoint::new(anchor, object).with_local_anchor_1(Vector::X * 100.0));
+ commands.spawn(
+ FixedJoint::new(anchor, object)
+ .with_local_anchor_1(Vector::X * 100.0)
+ .with_rotation_offset(PI / 4.), // <--- NEW
+ );
Original output
https://github.com/user-attachments/assets/0e206743-37c5-4453-b4cc-d9cf3339d114
New output with rotation offset applied
https://github.com/user-attachments/assets/5429ceb8-196b-486c-9adf-812c10f894eb
Caveat
I've only visually confirmed this looks right in 2d.
Hopefully the 3d version of my get_rotation_difference is correct.
Changelog
- Add
FixedJoint::with_rotation_offset