About the collision "hits"


At the first time, my player didn’t move anywhere but already get 1 hit.
I don’t know is it the player touch the floor?
My player can get 1 hit for touching the wall.
how can I fix it? thank you very much!

Hi Holyjosh,

Welcome to our community! :slight_smile:

I don’t know is it the player touch the floor?

Yes, the 1 hit could be caused by the floor. Our code increments hits whenever the player collides with another collider. There is no restriction (yet).

A quick fix would be:

private void OnCollisionEnter(Collision other) 
{
    if (other.gameObject.name == "Plane") { return; }

    // your code where you increment the hits
}

return; terminates the method immediately.

Did this fix it? :slight_smile:


See also:

2 Likes

Yes, I fixed it!
Nina, very grateful for your help! :pray:

1 Like

You’re welcome. :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms