Ignoring the guy who sent me

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.

So I found a similar question over here :

The basic idea is :
1 ) When you instantiate your monster set a unique variable in its class.
2 ) When you instantiate the fireball set the variable in the fireball to the same as the monster.
3 ) If the values are the same, don’t destroy.

You pass the variable like this from the monster’s class to the fireball :
var zBullet = Instantiate(bullet, transform.position, Quaternion.identity);
zBullet.playerNum = playerNumber;