- Home /
Copy world rotation cordinate
I have a cannon and I need to be rotated as the main camera, how can i do this? sorry for bad english, i'm italian
You need to provide a more detailed explanation. If you just want the two rotations to match, in your cannon script you would do:
transform.rotation = Camera.main.transform.rotation;
...but I suspect you want something more complicated.
Assu$$anonymous$$g those small guns on the top of the dome are what you are talking about, and assu$$anonymous$$g the camera you are looking through is the one tagged Camera$$anonymous$$ain, then the rotation did not work because of the way the guns are modeled. In unity it is expected that the front of an object is the side facing positive 'z' when the rotation of that object is (0,0,0). So you need to either fix your guns in the modeling program, or you can use an empty game object as a parent and rotate the visible child gun to face positive 'z' when the parent's rotation is (0,0,0).
Note if you are trying to get the guns to face the object hit by the crosshairs, that is a different one than just matching the guns to the rotation of the camera.
Answer by EDevJogos · Jul 30, 2014 at 08:48 PM
If it's C# it's like robertbu said, but try:
"Cannon".transform.rotation = new Quarterion(Camera.main.transform.rotarion);
Your answer
![](https://koobas.hobune.stream/wayback/20220613155410im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Move object relative to its axis 2 Answers
Converting Raycasted Point to Local Space 2 Answers