Using Tags in Collision
Reply on sbox.game-
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; } } -
Hi, the problem is that
GameObjectis 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.