Need help to spawn new objects in the game scene after a collision

Hello, i’m new to unity and I’m trying to make a new object appear after a collision, but i’m getting an error on this code plus I really have no idea how to add the collision as a trigger for this, at least inside the code.

using UnityEngine;
using System.Collections;

public class RandomPlacement : MonoBehaviour {

public GameObject MUG2;
public Vector3 spawnSpot = new Vector3(0,2,0);

void Start() {
GameObject MUGSpawn = (GameObject)Instantiate(MUG2, new Vector3(0,2,0), transform.rotation);
}

void Update() {
}
}

You need to use code tags, see the first posts on this forum. And also, it would help if you posted the error message.

Collision and Trigger are 2 separate things. They send different messages/callbacks and have a different setting in the collider.
If you have a script on either object involved in the trigger/collision, you can spawn an object inside OnTriggerEnter or OnCollisionEnter. :slight_smile:

That help?

Agreed that you should also format the code with code tags and explain what (and where) the error is. We are not mind readers :slight_smile: heh.