Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

How do I make an if collision in unity

A topic by game bread created Jun 07, 2024 Views: 116 Replies: 2
Viewing posts 1 to 3

ive looked online but none worked

Submitted

You make a collision by hitting two physics objects against eachother. You reference that collision in C# scripts with one of the following, depending on your needs: OnCollisionEnter() OnCollisionExit() OnCollisionStay()

Submitted

void OnCollisionEnter(Collision collision) {

   if(collision.transform.CompareTag("Spike"){

     health--;

     Destroy(collision.transform.gameObject);

}

}