Spawning enemys by collision

Hello guys,

I want to make i quick enemy script for my game, my ideia is to instantiate the enemy whenever my character is in contact with a floor that got the “spawn” tag on it.

How can i do this?

Thank you.

Hello. That should be quite simple:

Just add the following script to the player:

public GameObject EnemyToSpawn; // To assign the enemy in the inspector

void OnCollisionEnter(Collision collision)
{
     if (collision.collider.tag == "spawn")
     {
          GameObject newEnemy = Instataniate(EnemyToSpawn);
          Vector3 spawnPoint = collision.contacts[0].point;
          // add offset for enemy size;
          SpawnPoint.y += 0.5f; // example
          newEnemy.transform.position = spawnPoint;
     }



}