- Home /
translate kinematic rigid body while affecting velocity of child attached with spring joint
I have the following setup:
kinematic rigid body with a child rigid body attached thru a spring joint. That is, in the child, the connected rigid body is its parent, the kinematic one.
I translate this kinematic rigidbody by setting its transform in response to user input (Y Input axis = speed up / down).
Basically, this:
Note that the parent doesn't have a collider nor a mesh. This is because it's really only the child that will be visible in game and that I care about colliding with other stuff.
What I'm trying to achieve is that, if I'm 'accelerating' the kinematic body forward and all of a suden I break, have the child keep moving forward for a bit, before going back into place as a result of the spring. That is, I need momentum if you will. But what happens is that, while if I add a force to the child it will oscillate as expected cause of the spring, the parent's translation obviously does nothing in terms of imparting an acceleration in the child as it moves forward. I'm wondering if there is a way to do this with my setup (i.e.: dynamic body attached to a kinematic parent via a spring).
I tried rigidbody.MovePosition
but it doesn't seem to affect the kinematic body, though I might just be using it wrong.
Just in case, the reason why I make the parent kinematic and translate it via it's transform instead of having it be dynamic and add forces to it is cause I'm having it follow a bezier path and otherwise I'd need to calculate several forces to keep it moving on the path. Instead, I'm calculating acceleration, speed (not velocity) and position myself and keeping the body always on track by evaluating the bezier function and assigning the right values to transform.position
and transform.forward
.
Answer by saldavonschwartz · Dec 04, 2014 at 08:58 AM
One way I found around it is by making the parent non-kinematic instead (like it was pointed out, this is not necessary), and translating it via rigid body.MovePosition()
instead of transform.position
.
You can move it with rigidbody.$$anonymous$$ovePosition() even if it's marked as kinematic. And it should update the joint as well.
true, I just tried it out. I think before I thought I couldn't move it if it was kinematic, but obviously I had something else wrong.
Your answer
Follow this Question
Related Questions
Kinematic Rigidbody collision detection 1 Answer
Collision Detection for Kinematic Rigidbodies 0 Answers
Kinematics: Trying to get an object to land at a known point 1 Answer
Rigidbody hinged to moving kinematic rigidbody is NOT constrained 0 Answers
Moving a player on a rigidbody platform that can collide 2 Answers