- Home /
Elicopter Gun Looking at a crossair
Hi guys, i have this question for you: I have an elicopter made by me, this copter has a machine gun in the front that should rotate looking at a crossair that i drawed. This gun have 4 parts:
1."GunA" is the main part of the turret, that should rotate only on the Y axis. 2."GunB" is the second part of the turret, that should rotate only on the X axis. 3."GunC" is the minigun, that is children of the GunB object and should rotate fast on the Z axis. 4.the Muzzle object, where are instantiated bullets.
Now my question is: "How can i rotate this parts only on the X,Y,Z axis and make them looking at the crossair?" Thanks for the reading, bye ;)
Answer by DGArtistsInc · May 06, 2012 at 03:24 PM
OK first of all does your crosshair ever move on the screen? If not i would put an empty gameObject right in front of the helicopter. Make it a child to the helicopter then make the gun rotate to look at the empty gameObject with :
transform.LookAt(//put empty gameObject Here);
Answer by TheBombix · May 06, 2012 at 04:36 PM
hi DGArtistsInc, i have a Camera that is looking at the copter and the crosshair moves with the camera, so you can look around and shoot where you want.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071145im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Bullets getting stuck in air 1 Answer
JavaScript - FireMode Toggle Help 1 Answer
Need help with gun script to reduce the gun's rate of fire 1 Answer
Gun movement 1 Answer
Problem with "if" statements 1 Answer