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. Dismiss Notice

onTriggerEnter2D

Discussion in '2D' started by tugbaydogdu92, Dec 20, 2020.

?

onTriggerEnter2D çalışmıyor

  1. onTriggerEnter2D

    0 vote(s)
    0.0%
  2. onTriggerEnter2D

    0 vote(s)
    0.0%
  1. tugbaydogdu92

    tugbaydogdu92

    Joined:
    Dec 20, 2020
    Posts:
    6
    onTriggerEnter2D kod satırı çalışmıyor sebebi ne olabilir. prefabs olan mermi ve balonum var mermi balona değdiğinde kaybolsun istiyorum fakat çalışmıyor değdiğine dair geri dönüt vermiyor. kodu ateş etmesi için yazdığım koda ekledim.
     

    Attached Files:

    • 2.PNG
      2.PNG
      File size:
      16.8 KB
      Views:
      278
    • 3.PNG
      3.PNG
      File size:
      14.5 KB
      Views:
      285
    • 1.PNG
      1.PNG
      File size:
      8 KB
      Views:
      272
  2. BABIA_GameStudio

    BABIA_GameStudio

    Joined:
    Mar 31, 2020
    Posts:
    488
    Translation:
    Remove
    public
    from your method definition. Not sure if you can have that method as public (I don't think I have ever seen anyone trying to do that before).

    It is supposed to be
    OnTriggerEnter2D
    not
    onTriggerEnter2D
    . Capitalisation matters when coding.

    I would also recommend posting in English next time so people don't have to translate what you have posted before they can help. Even using Google Translate would be fine (it's what I did).
     
    tugbaydogdu92 likes this.
  3. tugbaydogdu92

    tugbaydogdu92

    Joined:
    Dec 20, 2020
    Posts:
    6
    First of all, thank you very much. I did it the way you said and it worked. I'm very happy. I am so inexperienced in this forum and coding, sorry for making you busy about translating etc.. , I will act in accordance with your recommendations from now on.
     
  4. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    It shouldn't make a difference. Making the method
    public
    just means other scripts can call it, which is likely not necessary, but it wouldn't prevent the Unity callback from working.
     
    tugbaydogdu92 likes this.