mouse orbit + gun attached to the camera howto add momentum to the gun?

Hello,

I’m currently working on a space shooter game.

I’ve got a camera that orbit around a target. I’m making it turn using the angles of the Y axis of the rotation.

I need to attach a cylinder below the camera and have it follow the camera movement but with a delay. The cylinder needs to be parallel to the axis of the camera.

Here is a drawing that explains what I’m trying to achieve (it’s drawn in top view)

I was looking into the hinge joint, but when using rigidbodies I get really weird effect going on. I guess it comes from the fact that I’m not using forces on the camera at first but I’m not sure.

If someone can point me to the right direction it would be much appreciated.

Thanks a lot for your help

B.

Implementing a momentum is not a simple task but I had another idea: I don’t know if it is good, but you could cache your camera positions by saving them in a list (not necessary frame by frame… maybe 1 every 0.5 seconds is fine) and then start a delayed coroutine that will step by step give the positions from the list to your cylinder, so that after the delay amount, your cylinder will have the same position of the camera.

Just saying… :stuck_out_tongue: