Code : Tout sélectionner
using UnityEngine;
using System.Collections;
public class Target : MonoBehaviour {
public bool X;//Boolean a cocher si nous voulons que l'objet bouge en x
public bool Y;//Boolean a cocher si nous voulons que l'objet bouge en y
public bool Z;//Boolean a cocher si nous voulons que l'objet bouge en z
public Transform target;//target = nord
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (X) {
gameObject.transform.LookAt(new Vector3(target.position.x, 0, 0));
}
if (Y) {
gameObject.transform.LookAt(new Vector3(0, target.position.y, 0));
}
if (Z) {
gameObject.transform.LookAt(new Vector3(0, 0, target.position.z));
}
if (X && Y) {
gameObject.transform.LookAt(new Vector3(target.position.x, target.position.y, 0));
}
if (Z && Y) {
gameObject.transform.LookAt(new Vector3(target.position.x, target.position.y, 0));
}
if (X && Z) {
gameObject.transform.LookAt(new Vector3(target.position.x, 0, target.position.z));
}
if (X && Z && Y) {
gameObject.transform.LookAt(target.position);
}
}
}