Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

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

Discussion in 'Scripting' started by BooBi, Feb 24, 2014.

  1. BooBi

    BooBi

    Joined:
    Jan 18, 2010
    Posts:
    534
    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) $Explanation-05.jpg

    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.
     
  2. Eugenio

    Eugenio

    Joined:
    Mar 21, 2013
    Posts:
    191
    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.... :p
     
unityunity