Hi , i have a shoot that’s make a spherical shock , and the shock causes an amount of damage every second , it works with my character but it wouldn’t work with a cannon , the cannon have a collider and a trigger , this is the colliding code of the cannon
function OnCollisionEnter(collision : Collision)
{
if(collision.gameObject.tag == “Shoot”)
{
collision.gameObject.BroadcastMessage("Hit",gameObject);
}
if(collision.gameObject.tag == “SmallShoot”)
{
collision.gameObject.BroadcastMessage("Hit",gameObject);
}
if(collision.gameObject.tag == “Hit”)
{
collision.gameObject.BroadcastMessage("Hit",gameObject);
}
}
function OnTriggerEnter(Hit : Collider)
{
if(Hit.gameObject.tag == “Trap”)
{
Hit.gameObject.BroadcastMessage("Hit",gameObject);
Damaged = true;
}
if(Hit.gameObject.tag == “Shoot”)
{
Hit.gameObject.BroadcastMessage("Hit",gameObject);
Damaged = true;
}
if(Hit.gameObject.tag == “SmallShoot”)
{
Hit.gameObject.BroadcastMessage("Hit",gameObject);
}
}
function OnTriggerStay(Stay : Collider)
{
if(Stay.gameObject.tag == “SmallShoot”)
{
Stay.gameObject.BroadcastMessage("Hit",gameObject,SendMessageOptions.DontRequireReceiver);
}
}
function Damage (Damage : float )
{
if(!NoHealth)
{
Health.localScale.x -= Damage / (Sturdy * 0.1);
}
if(NoHealth)
{
Instantiate(Destroyed,transform.position,transform.rotation);
Destroy(gameObject);
}
}
and thanks very much
Please- code-dumps are pretty ugly when they're that badly formatted. (they're pretty ugly anyway, because nobody wants to look through an entire script to find the one line that's making an error)
– syclamoth