- Home /
Question by
Ryki · Apr 24, 2014 at 10:30 PM ·
objectsturretclass objectturrets
making Turrets
I am now a turret to make and have two objects, and each has its own function. only one object needs to run in the y axis and two object should run in the x axis only do I have the code built up in this way:
public class Turretgun : MonoBehaviour
{
public Transform target;
public float rotateSpeed = 45;
// Update is called once per frame
void Update () {
var localTarget = transform.InverseTransformPoint(target.position);
localTarget.y = 0;
var targetRot = transform.rotation * Quaternion.LookRotation( localTarget );
transform.rotation = Quaternion.RotateTowards( transform.rotation, targetRot, Time.deltaTime * rotateSpeed );
}
}
The code I use when both objects only changed the x and y axis only. there is no other way to be able to work together?
Comment
Is this question from a lab assignment or school project? The exact same question with the same requirements has been asked often lately.
I don't know what that means, but search UA/Google and you'll find this question/answer