How to "create a ground"?

  • Hi, I’m new to Unity, so I have been
    doing the Tutorials, but I always
    change something because I want to
    understand everything and not just
    copy paste.

  • So I started doing the “Flappy Bird
    Style Game” in 2D, but instead of a
    bird; I made a Samurai, and of course
    a Samurai doens’t die when he touches
    on the floor, I have puted a box
    collider in the ground so he doesn’t
    pass the ground an stay on it, but
    with the GameOver script active he
    dies, with this code:

    void OnCollisionEnter2D()
             { 
                 isDead = true;
                 anim.SetTrigger("Die");
                 GameControl.instance.SamuraiDied();
             }
    
  • And I would like you to help me
    change it, so I could put the samurai
    on the floor without diyng but if he
    goes against a wall he dies. Thank
    You.

If I’m not wrong, let’s say you want it to collide with some kind of wall, then you need to add to the wall object a Tag like “Wall” and to the floor a Tag like “Ground”. Then you have to make sure it’s only triggered on the Wall tag, and not in any other.

You can create and set tags in the top left of the inspector once you’ve selected an object.

If I put Static, they just don’t move and are always in front of the Samurai, because like Flappy bird, it’s the world and walls that move, the player just goes up and down.