How to make all Guns look at the same point
Hi ! I have a little problem with my Unity 3D Game. I need that all my guns point towards a same point, controlled by the mouse. Look at this picture :
The first gun is pointing correctly to the mouse position, because in game, the camera is situtated at this gun (first person). But the second one (underlined) point also at a rotation, but this rotation is the same as the other, but I want to correct this rotation to point at the direction the first gun is pointing.
Here is my code that control the rotation for each gun :
gun.transform.Rotate(new Vector3(-Input.GetAxis("Mouse Y"), 0, 0) * Time.deltaTime * 200);
arm.transform.Rotate(new Vector3(0, Input.GetAxis("Mouse X"), 0) * Time.deltaTime * 200);
Thank you for your help !
EDIT : Basically the "gun" is the cannon of the gun, he can only rotate up and down. The gun is a child of arm, wich is the pivot point of the gun y rotation. That arm is rotating to left and right around a circle. What I want is that all my gun point towards a same point, instead of a same directiion, because now, only the first gun is pointing correctly, the other are pointing at the same direction as the first, but it's incorrect, they should point where the first is actually pointing.
Answer by amimox · Mar 10, 2016 at 09:13 PM
Help please ? Maybe some Vector math can help, I am trying to figuring out how. If I substract the first gun arm rotation with the other one, I will get 0, they are the same... All I want is a correction number to the seconds gun arm rotation.
Your answer
Follow this Question
Related Questions
Rotate character 0 Answers
Hand and gun rotation problem, Third Person Shooter 1 Answer
Camera Rotation every time a key is pressed 0 Answers
Strange rotation behaviour 0 Answers
Rotation Flicker in 2d platformer gun 0 Answers