- Home /
Get a point trailing behind a tumbling rigidbody
I have a sphere that is fired out of a cannon and has to be followed by a camera. I am currently using a modified version of smooth follow script. My problem is that the sphere will bounce off things in the scene and will begin to tumble on all 3 axis due to collisions. When the tumbling happens the forward vector of the sphere is now not relevant to the actual forward direction of travel of the sphere, causing the camera to basically become un-viewable. How would I get the position a few units behind the sphere relevant to its current direction of travel?
I can draw a diagram to better explain this if its not totally clear? I've searched around the forums and come up with stuff but none of it takes into account the tumbling nature of the sphere. If there is a post I've over looked I'm eager to know! :)
Many thanks in advance!
Answer by CrazyEoin · Dec 06, 2012 at 01:04 AM
I finally got back to my home computer to continue work on this. Thanks for your answer Rob, you understood the question correctly but none of those suggestions did the job. I went back to basics and looked at it from scratch and got it working in the end.
I used the .normalized function of the Vector 3 and this gave me the direction of travel, after that all I needed to do was multiply this by a distance and add this to the origional position of the ball, here is my code which probably explains it better:
Vector3 dirOfBall = Ball.rigidbody.velocity.normalized;
dirOfBall = Ball.transform.position + ((dirOfBall * -20) + new Vector3(0,height,0));
MainCamera.transform.position = Vector3.Lerp (MainCamera.transform.position,dirOfBall, Time.deltaTime * damping);
Rob, thanks for your input and I hope this is useful to anyone else stuck with this kind of problem.
you should mark this as answered if it indeed solved your problem
Apologies, I though I had marked this as answered. Thanks for re$$anonymous$$ding me.
Your answer
![](https://koobas.hobune.stream/wayback/20220613084558im_/https://answers.unity.com/themes/thub/images/avi.jpg)