Movimiento ida y vuelta con rotación.
using System.Collections;
public class enemy : MonoBehaviour {
public Vector3 move;
public float x;
public float y;
// Use this for initialization
void Start () {
x = -1;
}
// Update is called once per frame
void Update () {
transform.Translate (new Vector3 (x, 0, 0) * Time.deltaTime);
if (transform.position.x < -1.50) {
x=-1;
transform.rotation = Quaternion.Euler(new Vector3 (0, 180, 0));
}
if (transform.position.x > 4) {
x = -1;
transform.rotation = Quaternion.Euler (new Vector3 (0, 0, 0));
}
}
}
No hay comentarios:
Publicar un comentario