Slider barra de vida explicado con utilidad, Unity, video y script; y cambio de GameObject;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ARRASA : MonoBehaviour {
public int damage;
public int vidaEnemigo;
public Slider BarraVidaEnemigo;
public Rigidbody cubo;/// pruebas
void Update () {
BarraVidaEnemigo.value = vidaEnemigo;
}
void OnTriggerEnter(Collider other) {
// if (other.gameObject.CompareTag ("Player")){
if (other.gameObject.CompareTag ("caca")){
vidaEnemigo-=damage;
if (vidaEnemigo <= 0) {
Destroy (this.gameObject);/////destruye funciona
// Application.LoadLevel (0);
Rigidbody p = Instantiate(cubo, transform.position, transform.rotation);////pruebassss
// Application.LoadLevel (1);///cambia la escena donde quiero funciona
}
}}
}
No hay comentarios:
Publicar un comentario