have different weapons, with one i would like to shoot real bullets, so i attached these two scripts to the bullet, but only the first works. are they interfering?
using UnityEngine; using System.Collections;
public class proj_giocatore_distruggi : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void OnCollisionEnter (Collision collision) {
GameObject prefab = Resources.Load ("esplosione") as GameObject;
GameObject esplosione = Instantiate (prefab) as GameObject;
esplosione.transform.position = transform.position;
Destroy (esplosione, 2);
Destroy (gameObject);
}
}
////This is the second script
using UnityEngine; using System.Collections;
public class danno_proj_giocatore : MonoBehaviour {
public int danno = 100;
// Use this for initialization
void Start () {
}
void OnTriggerEnter(Collider Other)
{
//Is colliding object a player? Cannot collide with enemies
if (!Other.CompareTag ("enemy"))
return;
//Get PlayerController object and update cash
Enemy_Drone EN = Other.gameObject.GetComponent ();
//If there is a PC attached to colliding object, then update cash
if (EN)
EN.Health += danno;
}
}
↧