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

Need help !2D stop when collsion to other objects

Discussion in '2D' started by andy30929, Mar 21, 2020.

  1. andy30929

    andy30929

    Joined:
    Feb 26, 2018
    Posts:
    17
    Capture.PNG
    I am new to unity for learning and, face some problems when making a first game.
    The player push the tree out when collision happen, however i want to stop the player when walk to the tree.

    also i hope to know to change these in the player script.

    if (okay == true){
    i can press the tree // how should i code this ?
    }else{
    i cannot press the tree // how should i code this ?
    }

    what should i code ? Need help. :D
     

    Attached Files:

  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    The tree should not be moving so it set the Rigidbody2D body-type to "Static". Static bodies cannot move and don't react to forces such as those involved in collision, gravity etc.
     
  3. andy30929

    andy30929

    Joined:
    Feb 26, 2018
    Posts:
    17
    Thx, but i cannot find the static button? Or do
    you mean for script? Can you give more details?
     
  4. Ocean_Aka

    Ocean_Aka

    Joined:
    Mar 18, 2020
    Posts:
    3
    it is at the top
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    > set the Rigidbody2D body-type to "Static"

    It's the first property listed on the Rigidbody2D in the inspector. You have it set to "Dynamic".