spawn object on collision

i’m trying to make it so that the player shoots a projectile, and when that projectile collides with something, then a game object spawns at that location.

however, whenever the projectile collides with something, nothing happens.

void onCollisionEnter (Collision collision) {

	GameObject prefab1 = Resources.Load ("gelatin") as GameObject;
	GameObject gelatin = Instantiate (prefab1) as GameObject;
	gelatin.transform.position = transform.position;

	Destroy (gameObject);

does anyone know what i’m doing wrong?


Hopefully this helps.

using UnityEngine;

using System.Collections;

//governs behavior of projectile

public class Blaster : MonoBehaviour


private Transform myTransform;

private float projectileSpeed = 7.5f;

private bool expended = false;

private RaycastHit hit;

private float range = 1.5f;

private float expireTime = 5;

public GameObject ProjectileExplosion;

void Start () 
	myTransform = transform;

void Update () 
	myTransform.Translate(Vector3.up * projectileSpeed * Time.deltaTime);
	if(Physics.Raycast(myTransform.position,myTransform.up, out hit, range) && expended == false)
		if(hit.collider.tag == "floor")

			expended = true;
			Instantiate(ProjectileExplosion, hit.point, Quaternion.identity);
			myTransform.GetComponent<Renderer>().enabled = false;
			myTransform.GetComponent<Light>().enabled = false;

IEnumerator DestroyMe()
	yield return new WaitForSeconds(expireTime);
	Destroy (myTransform.gameObject);