hello, i’m trying to do a raycast from my enemy to check if the enemy can see the player, but i can’t able to check the tag or name from the result list of hits.
in c# i did this
foreach (RaycastHit hit in hits)
{
if (hit.transform.tag == "Player")
Debug.Log("player found");
}
but i’m using this in bolt

but when my enemy is trying to check for the player i’m getting this error in the unity editor

how can i do this tag check for any of the hit results ?
thanks in advance for all the help.
Hi, i don’t know Bolt, but the message seems logic. You are testing a RaycastHit in your script without passing it to a gameobject.
foreach (RaycastHit hit in hits)
Try to get the gameobject in your foreach :
GameObject player;
foreach (RaycastHit hit in hits)
{
if (hit.transform.tag == "Player") player = hit.transform.gameobject;
}
I hope this helps.
@MlleBun i don’t have any problem with the c# code, the problem is with the bolt code, i shown what i used to use in c# to check the tag or the name from the hits result after when i use a raycast but the problem is that bolt didn’t return the tag or name using the same code.
got it working, for anyone with this same issue, here is the node to use

2 Likes