Help with getting a variable with Raycast

Everyone I could use some help, I’m using Raycast to throw a punch. The problem is when trying to check if the opponent blocks, the block is just a bool. Here’s the code, thanks for at least trying to help.

RaycastHit rayHit;
if (Physics.Raycast(transform.position, transform.forward, out rayHit, attackRange))
{	
	if(??)
	{
		damageToDeal /= 2;
	}
rayHit.collider.SendMessageUpwards("ApplyDamage", damageToDeal, SendMessageOptions.DontRequireReceiver);
			}

Why not stick this in the targets ApplyDamage Function instead?

Seems to be working, but if there is a viable option the way I was looking for that would still be cool to know. Thanks for pointing out the best option.

if ( hit.collider.GetComponent(Enemy).isBlocking )

But you don’t want to be accessing that in that manner. Definitely belongs in the ApplyDamage function. Otherwise, debugging will be a pain. :slight_smile: