Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Problem with CharacterController variable isGrounded

Discussion in '2D' started by Kingfish, May 17, 2014.

  1. Kingfish

    Kingfish

    Joined:
    May 17, 2014
    Posts:
    1
    I have a character, and I want to make it jump. However, I only want it to be able to jump if it is touching the ground (no double jumps). I want to do this using the isGrounded variable, but how do I make something that qualifies as "ground"? I have my character on a simple sprite image of the ground with a huge mass so that the ground isn't pushed by the character, which is affected by gravity (the ground is not). What do I need to do to make ground that triggers the isGrounded function on my character?
     
  2. alKaszL

    alKaszL

    Joined:
    Jan 26, 2013
    Posts:
    8
    Tags will work for this. Just create a tag for the ground, apply it to anything that is grounded, and when the isGrounded object comes into contact with anything with that tag it will return true. I believe you could also just use layers here, using the same method. Search through Unity Answers as it has many solutions to quick problems like this :)