- Home /
Turret script. Making it aim in heigth only.
I am working on a turret script and i have gotten the turret which rotates only around its Y axis to work. But i am not quite sure how to the the cannon which is a child of the turret and should only rotate around the Z axis (aim barrel up and down) to work properly.
How can i get the cannon barrel to aim aim at the target and only have it rotate in the Z axis?
Answer by bernardfrancois · Jan 20, 2013 at 09:18 AM
Did you try the following?
Transform barrel = transform.Find ("Barrel"); barrelTransform.localRotation = Quaternion.AngleAxis (turretAngle, Vector3.right);
You may have to change Vector3.right to Vector3.up or Vector3.forward in this line of code, depending on the axis containing the longest direction (I'd recommend reexporting the object though, as it would make it more intuitive while programming).
Your answer
Follow this Question
Related Questions
Vector3.Angle making my object oscilate... 2 Answers
Aiming to gameobject 2 Answers
Freeze Camera Rotation that is attached to the object in certain moments 0 Answers
Turret Continuing to Max Rotation - Following Mouse Cursor 0 Answers
How can I rotate a tank's turret back to the starting turret position? 2 Answers