Andrés Eraso Zambrano
Pedro Daniel Gómez Esparza
Valentina Leal Vanegas

Moderator: julianmartinez16
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Unidad : MonoBehaviour {
public GameObject ruta;
private int indice;
private Vector3 posicion_siguiente;
private float vel = 1;
private float distancia_punto = 0.5f;
// Use this for initialization
void Start () {
posicion_siguiente = ruta.transform.GetChild(0).position;
}
// Update is called once per frame
void Update () {
Vector3 dir = posicion_siguiente - this.transform.position;
this.transform.position += dir * vel * Time.deltaTime;
if(dir.magnitude<= distancia_punto)
{
if(indice+1<ruta.transform.childCount)
{
indice++;
posicion_siguiente = ruta.transform.GetChild(indice).position;
Debug.Log("xs" + posicion_siguiente.x + "ys" + posicion_siguiente.y);
}
}
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Torrecita : MonoBehaviour {
public GameObject enemigo;
public float distancia_umbral = 2;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float distancia= (enemigo.transform.position - this.transform.position).magnitude;
if(distancia<= distancia_umbral)
{
Debug.DrawLine(this.transform.position, enemigo.transform.position, Color.red );
}
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Base : MonoBehaviour {
public GameObject torre;
void OnMouseDown()
{
GameObject temporal;
Vector3 pos = this.transform.position;
pos.y = pos.y + .4f;
temporal = Instantiate(torre);
temporal.transform.position = pos;
temporal.layer = 5;
Destroy(this.gameObject);
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour {
public GameObject enemigo;
public float tiempo = 3f;
public Transform[] puntoSpawn;
// Use this for initialization
void Start () {
InvokeRepeating("Spawn", tiempo, tiempo);
}
// Update is called once per frame
void Spawn () {
int spawnPointIndex = Random.Range(0, puntoSpawn.Length);
Instantiate(enemigo, puntoSpawn[spawnPointIndex].position, puntoSpawn[spawnPointIndex].rotation);
}
}