Creating and Using QAngleConstraintObject - erayzesen/godot-quarkphysics GitHub Wiki
QAngleConstraintObject Documentation
QAngleConstraintObject
applies an angle constraint between three specified particles in the QMeshNode
. You define the minimum and maximum angles for the constraint, and during the simulation, the angle between these three particles is maintained according to the specified rigidity level. This is particularly useful in advanced position-based soft body simulations.
How to Create a QAngleConstraintObject?
QAngleConstraintObject
instances are not part of the scene tree; they are created via code. You don't need to manually delete them. If Godot finds no references to them, they will be automatically removed.
To configure a QAngleConstraintObject
, it requires five parameters:
- particle_object_a: The first particle.
- particle_object_b: The second particle.
- particle_object_c: The third particle.
- minimum_angle: The minimum angle for the constraint.
- maximum_angle: The maximum angle for the constraint.
#Create a QAngleConstraintObject
var my_angle_constraint=QAngleConstraintObject.new()
#Default- Configure
my_angle_constraint.configure(particle_object_a,particle_object_b,particle_object_c,min_angle,max_angle)
#Alternative - Configure Angle Constraint via Local Positions of Particles.
my_angle_constraint.configure_with_angle_of_local_positions(particle_object_a,particle_object_b,particle_object_c,angle_range)
#Set Rigidity of the Constraint- The value must be between 1.0 and 0.0
my_angle_constraint.set_rigidity(0.5)
#Add angle constraint to the mesh
my_mesh.add_angle_constraint(my_angle_constraint)
How Does QAngleConstraintObject Work?
In each frame of the physics simulation, the angle between the three particles is calculated. If the angle is below the minimum or above the maximum, the positions of the particles are adjusted based on the defined rigidity level to enforce the constraint.