mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
added the corresponding ball joint motor for 2d
This commit is contained in:
@@ -475,6 +475,34 @@ impl Joint {
|
||||
self.set_motor_params(motor_params);
|
||||
Ok(())
|
||||
}
|
||||
/// Makes the [`BallJoint`] to restore its original orientation with motor torque.
|
||||
///
|
||||
/// Acts as a flexible fixed joint that tolerates some angular movement and tries to restore the original orientation.
|
||||
///
|
||||
/// For flexible fixed joints that tolerate some translational movement, consider using a [`PrismaticJoint`] and call [`Self::set_motor_target_position_as_prismatic`].
|
||||
///
|
||||
/// This function essentially calls [`Self::set_motor_target_angle_as_ball`] with a target angle of 0 radians. It is here to be symmetric with its 3D version, which is more useful in a 3D context.
|
||||
///
|
||||
/// /// Call [`Self::disable_motor`] to stop the motor and remove the spring effect.
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `stiffness` - Controls how fast the joint will try to restore its original orientation.
|
||||
/// * `max_torque` - The maximum torque this motor can deliver.
|
||||
/// * `damping` - Penalizes high angular velocities to avoid overshooting the original orientation. A higher damping value will result in a smoother transition to the original orientation.
|
||||
/// # Errors
|
||||
/// If the joint is not a [`BallJoint`], the function will do nothing and return an Err.
|
||||
/// # Notice
|
||||
/// The rigid bodies attached to the joint may fall asleep anytime regardless whether the motor is enabled or not.
|
||||
///
|
||||
/// To avoid this behavior, call this function periodically or call [`RigidBody::set_can_sleep`] on the rigid bodies with "false".
|
||||
pub fn set_motor_resistive_torque_as_ball(
|
||||
&mut self,
|
||||
stiffness: f32,
|
||||
max_torque: f32,
|
||||
damping: f32,
|
||||
) -> Result<(), String> {
|
||||
self.set_motor_target_angle_as_ball(0.0, stiffness, max_torque, damping)
|
||||
}
|
||||
|
||||
/// Disables the motor of the joint assuming it is a [`BallJoint`] or [`PrismaticJoint`].
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user