OnCollisionEnter won't Work

First off all sorry for my english
I have an object that walk on X axis back and forth. every time i press on the object its destroy it self and transform.position to a new position on the X axis and gives a score value.

public void OnMouseDown()

{

	bloodCubeInstence = Instantiate(bloodCube, transform.position, Quaternion.identity) as GameObject;
	transform.position = new Vector3 (transform.position.x, Random.Range (-7, 7), transform.position.z);
    gameController.AddScore(scoreValue);

}

now i have an object thats fall down on Y axis and every time i press on it its make a partical effect.

NOW! i want that the partical effect will have same “effect” that i get from “OnMouseDown”

public void OnCollisionEnter(Collision col)
{
	GingerFind = GameObject.Find("GingerWalk");
	mouse = GingerFind.GetComponent<Mouse>();
	
	mouse.OnMouseDown();
	

}

but nothing happened :confused:
please help me!

1 Answer

1

Try this script:

public void OnCollisionEnter(Collision col)
{  
    bloodCubeInstence = Instantiate(bloodCube, transform.position, Quaternion.identity) as GameObject;
    transform.position = new Vector3 (transform.position.x, Random.Range (-7, 7), transform.position.z);
    gameController.AddScore(scoreValue);     
}