Please disregard; I made a bonehead mistake.
Can a moderator please delete this thread?
I just tried to add a change to a projectile class I made so the projectile would know who fired the projectile, and then ignore that person if they collide with them.
I had been using a system where the projectile ignored anyone with a set tag, but I want to change it so that it just ignores that one person.
I’m testing this with a simple monster that casts fireballs.
This is what I put in my projectile class:
public bool bCanHurtCaster;
public GameObject Caster;
[...]
protected void OnCollisionEnter2D (Collision2D col)
{
if(col.gameObject == Caster !bCanHurtCaster)
return;
[…]
}
This is what I put in my monster’s class:
protected virtual void CastFireball() {
GameObject thisFireball;
anim.SetTrigger ("Cast");
thisFireball = (GameObject)Instantiate(FireballPrefab, castOrigin.position, transform.rotation);
thisFireball.GetComponent<Projectile>().Caster = gameObject;
}
}
It was working fine when I had the projectile check for a tag to ignore, but now the fireball is instantly killing the monster.
Since I barely added two lines of code, the problem must be something simple in how I set this up. But I don’t know what I did wrong.
My best guess is that I improperly told the fireball which gameObject to ignore, but I don’t know what the correct syntax for that would be.