Obstacle Course - Scoring - Player Counts Ground

As many people have likely experienced already, if you use a simple shape with collider as your character and keep it slightly above the ground when the game begins it’ll fall to the ground and count as 1 score.

To solve this problem, I revisited the “Scorer” script and used an if statement with a CompareTag method to check to see if the collider the player was hitting did not have a “Ground” tag.

So I went into my object hierarchy, gave my “Ground” a “Ground” tag, and gave my walls a “Wall” tag. Then I wrote:

if(!collision.collider.CompareTag(“Ground”)) {

hits++;
Debug.Log(“Your statement here” + hits);

}

Now when the player falls to the ground, it doesn’t increment because it will only increment if it collides with a collider not tagged with “Ground”.

Since we have restrained the vertical axes you can lift a bit the player gameObject just enough to not touch the collider of the ground, for what we are going to do in this project i think is the easyest way to workaround the thing we do not know yet how exclude colliders.

Privacy & Terms