sorry for my bad English in advance. I am a newbie in unity. I want to know that if I have a gameobject which is standing straight up on floor. and if I hit it with ball(sphere), then the gameobject falls on floor. I want to add score every time when ball hits it and it falls on floor. I did use OnCollisionEnter() function. but sometimes when ball just touches the gameobject and if not hit hardly then the score is counted but gameobject not falls down on floor. so how can I achieve the accuracy so that whenever gameobject falls on floors, add score only if it falls! Pls help guys. I stuck here. Thanks in advance.
add to your gameobject*floor a tag floor or something like this
Then Write This
void OnCollisionEnter(Collision other){
if(other.gameObject.tag == “Floor”)
{
Score += 1;
}
This shoud get you started now you will gain score every time you touch the ground ,if you touch something else noting will hapen
I solved this… thanks all but its solved !
Instead of using the above code in OnCollisionEnter(). I Used it in Update().
void Update()
{
if (scr)
{
if(gameObject.transform.rotation.eulerAngles.z<300)
{
counts=counts + 10;
scr=false;
SetCountText();
}
}
}