Reset/jump constraint to the initial position
Posted: Tue Jan 31, 2023 1:31 pm
Hi,
I am using Generic6DofSpring2 constraints and I would like to find an easy way to reset the constraint to the initial position.
It is a quite particular case in which the parent body is static and the child (connected with the constraint) is dynamic (mass>0).
I am running the constraint with a motor, in velocity mode, so I can move the child in one axis (let's say x) from 0m to 1m:
[PARENT]
|<---------------------[CHILD]----------------------->|
0m 1m
What I want to achieve is the child to automatically jump to initial position (0m) if velocity is positive and it arrives to the upper limit. Kind of a loop effect. Important to mention that I want this to happen between two simulation steps!
The hard way, I guess, is doing the following:
- Detect when the child is at upper limit and velocity is >0.
- Then remove the constraint
- Move the child body to the initial position
- Set a new constraint and apply the velocity.
Is there any other way?
Thanks in advance!
I am using Generic6DofSpring2 constraints and I would like to find an easy way to reset the constraint to the initial position.
It is a quite particular case in which the parent body is static and the child (connected with the constraint) is dynamic (mass>0).
I am running the constraint with a motor, in velocity mode, so I can move the child in one axis (let's say x) from 0m to 1m:
[PARENT]
|<---------------------[CHILD]----------------------->|
0m 1m
What I want to achieve is the child to automatically jump to initial position (0m) if velocity is positive and it arrives to the upper limit. Kind of a loop effect. Important to mention that I want this to happen between two simulation steps!
The hard way, I guess, is doing the following:
- Detect when the child is at upper limit and velocity is >0.
- Then remove the constraint
- Move the child body to the initial position
- Set a new constraint and apply the velocity.
Is there any other way?
Thanks in advance!