Using Tags in Collision

Started by xraybeesx · 4 months ago · 1 reply · 83 views

#1
xraybeesx
Member
JoinedApr 2026 Posts19 Score1,160
I'm trying to use tags to discern what I'm colliding with, but I can't seem to get it working. I am using:


void ICollisionListener.OnCollisionStart(Collision collision)
		
{
	

	if ( GameObject.Tags.Has( "friendly" ) )
	{
			friends = true;
	}

	
}

#2
Omjihn
Member
JoinedMar 2026 Posts20 Score855
Hi, the problem is that GameObject is the current GameObject that has the component attached.

void ICollisionListener.OnCollisionStart(Collision collision)	
{
	if ( collision.Other.GameObject.Tags.Has( "friendly" ) )
	{
			friends = true;
	}
}

This fix make sure you retrieve the the other object like this:collision.Other.GameObject.
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.