- Home /
Tank Turret Movement By Mouse
My and a friend are currently working on a "Tank!" remake (just for fun) and we are using a Tank model that is two children (Top and Bottom) Now, I am using a WASD control method for the bottom treads but we want to make the turret rotate with the input of the mouse. We are also using the usual SmoothFollow.js to follow the tank but we also want the player to be able to use their mouse to aim and look. For some reason, I can't seem to get the tank turret to follow my mouse. I've looked on here for pointers but all the solutions aren't really fitting correctly. Any ideas?
Thanks in advance!
Answer by mister.keith · Jul 26, 2012 at 11:10 PM
I ended up using the MouseLook Script in the Standard Assets and restricted the rotation to just the X axis. Worked like a charm. :)
Answer by Meltdown · Jul 16, 2012 at 05:37 PM
You'll need to use a combination of ScreenToWorldPoint and Transform.Lookat to make your turret face the point in 2D space your mouse cursor is and translate it to 3D space.
Your answer
![](https://koobas.hobune.stream/wayback/20220613074242im_/https://answers.unity.com/themes/thub/images/avi.jpg)