Return to beginning of phase in C # [closed]

1

HereistheobjectthatIwantittogobacktothebeginning

Here'sthecharacter

Wellguys,I'mabeginnerandIneedtodeliverthisgameprojectforthismonthandIwantedtoseewhenthecharactertouchestheblockhereturnstothebeginningofthephase.

IdothisbuttheprogramdoesnotrecognizeanythingandthegamecontinuesandIdonotknowhowtodoit.Ididnotputalivingsysteminthecharacter.

Thecharacter,asIsaidbefore,Iamabeginnersotheremaybealotofthingswrong.   link

    
asked by anonymous 17.09.2018 / 17:59

1 answer

0

The conditions for a collision are:

  • Ensure that at least one of the objects has the RigidBody2D component.
  • Let both have collision boxes enabled.
  • That the script that controls this collision is in the object that will change position (in your case).
  • implement the function:
  • void OnCollisionEnter2D(Collision2D col)
    {
       if(col.transform.CompareTag("SuaTagAqui")){
          //seu código aqui
       }
    }
    

    In your script you are OnTriggerEnter2D that serves for colliders with the "IsTrigger" box selected.

        
    17.09.2018 / 19:42