Hi,
I have a system trying to modify the constraint (min, max, frequency, damping) of some PhysicsJoint (currently testing limited distance and limited DOF). I can see that from the entity debugger the values in the constraints are updated but they are not actually taking any effect at all. May I know are there any example codes showing how to do it correctly? thanks.
Hi there, i was experiencing a similar issue when i updated the values of a limited hinge joint during runtime.
However, as soon as the entity was moving, the joint also worked again. Another thing that also worked on stationary entites was to make only smaller, incremental changes to the constraint.
Did a further test on limited hinge joint and I can actually get it to work with the following simplified codes, except for the situation where the rigidbody (physicbody) is in “sleep” mode, which I need to manually move it a little bit to activate it to make this system work. However, I still cannot get limited distance and limited DOF to work.
Entities.ForEach(
(
Entity _entity,
ref PhysicsJoint PJ, // limited hinge joint
ref comp_data data) =>
{
var constraints = PJ.GetConstraints();
var c0 = constraints[0];
c0.Min = data.cur_angle;
c0.Max = data.cur_angle;
constraints[0] = c0;
PJ.SetConstraints(constraints);
}).ScheduleParallel();
The <Tests/JointTest/Modify Tests> test scene is changing the Joints. The associated script is here.