I have a piece of code in my game I already hate. The intention is to simply check whether a collision hits a terrain object, in case I want the collision to be handled in a specific way. I looked for a way to detect the terrain and went with this for now:
if (collision.gameObject.name == "Terrain")
{
movement.grounded = true;
movement.jumpTimes = 0;
}
Terrible! I’ve tried casting collision.gameObject to the Terrain class to get a satisfying bool, but that doesn’t work. Basicly my goal is to isolate the Terrain class and check for that instead of some arbitary instance name. I’m new to the codebase so I figured the answer is probably quite simple and I’m just not seeing it yet