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!

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.

I ended up using the MouseLook Script in the Standard Assets and restricted the rotation to just the X axis. Worked like a charm. :slight_smile: