- Home /
Make rigidbody freeze to an object's axis
Hello, I know I can freeze the position of a rigidbody along a global axis, but is there a way of freezing a rigidbody to an objects axis? Here's a little diagram to show you what I mean. Can I do this with a configurable joint? Thanks!
track.jpg
(52.2 kB)
Comment
Best Answer
Answer by ScroodgeM · Aug 17, 2012 at 08:00 AM
all what actually doing 'freezing along world axis' is just resetting every FixedUpdate it's speed component. so all you should do is reset your compounded speed component.
this is one of way to take only speed direction you need
so,
Vector3.Project(rigidbody.velocity, trackTransform.forward)
returns speed relative to track. apply it back to rigidbody and all slide speeds will be resetted to zero