Hi Unity,
I’m having a progress-stopping problem with my simple combat system. I’m trying to make it so that if a projectile hits a tag, it explodes and the transform is disabled. Later, an IEnumerator takes care of the destruction, but here’s the code (See below for explanation of the issue):
if(Physics.Raycast(myTransform.position,myTransform.up, out hit, range) &&
expended == false)
{
//If the collider has the tag of Floor then..
if(hit.transform.tag == "Floor")
{
expended = true;
//Instantiate an explosion effect.
Instantiate(blasterExplosion, hit.point, Quaternion.identity);
//Make the projectile become invisible.
myTransform.renderer.enabled = false;
//Turn off the light. The halo will also disappear.
myTransform.light.enabled = false;
//Turn off the particle emission
myTransform.particleEmitter.emit = false;
}
if(hit.transform.tag == "BlueTeamTrigger" ||
hit.transform.tag == "RedTeamTrigger")
{
expended = true;
//Instantiate an explosion effect.
Instantiate(blasterExplosion, hit.point, Quaternion.identity);
//Make the projectile become invisible.
myTransform.renderer.enabled = false;
//Turn off the light. The halo will also disappear.
myTransform.light.enabled = false;
The problem is, the projectile ignores the collider “RedTeamTrigger” and “BlueTeamTrigger” completely, as if it wasn’t there. However, it explodes and disables properly when it hits the “Floor” tag. What am I doing wrong here? I’ve checked the documentation and even completely rebuilt the game to make sure this was the real issue.
Thanks!
Addyarb