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

Tutorial about enemies (jumping on the top)

Discussion in '2D' started by bartlomiejobiadek, Apr 3, 2020.

  1. bartlomiejobiadek

    bartlomiejobiadek

    Joined:
    Mar 25, 2020
    Posts:
    5
    I'm so tired already, when I recognize you must pay in Game Maker I moved to Unity but I can't find any tutorial how to create enemies dieing when you jumping into them
     
  2. simple421

    simple421

    Joined:
    May 17, 2019
    Posts:
    18
    Make script and attach it to Player
    Code (CSharp):
    1.  
    2. private void Update()
    3. {  
    4.         RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down, range, enemyLayer)
    5.  
    6.         if (hit && hit.collider.CompareTag("Enemy"))
    7.         {
    8.             // Destroy enemy
    9.         }
    10. }
    11.  
     
  3. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    989
    I think easiest way is to put parent empty on enemies head, and have physics overlap sphere to detect collision, similar to death mechanic in mario
     
  4. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,802
    Seriously? Search google or youtube for "unity jump on head" or "unity goomba stomp". It's not exactly a new topic.
     
    eses likes this.
  5. interpol_kun

    interpol_kun

    Joined:
    Jul 28, 2016
    Posts:
    134
    The engine won't help you with your bad googling and asking the right question (or laziness, I guess, cause you can google your problem in a few seconds).
     
  6. bartlomiejobiadek

    bartlomiejobiadek

    Joined:
    Mar 25, 2020
    Posts:
    5
    Sorry guys, for real now i was searching now and found some. Its because i was really tired and wanted to talk with someone... :D
     
  7. mikkuelle

    mikkuelle

    Joined:
    Nov 12, 2020
    Posts:
    12
    I absolutely hate stupid people. Not the ones asking the questions but the ones that take the time to respond to the question with a smart ass remark. Google it. What the F*** do you think they thought about before taking even longer to write their questions here? Another note, what the F*** is the purpose of the forum if youre not getting questions answered? Sure aint to show off the S***ty homemade games ya'll try to make in the ever-changing, completely confusing after every update Unity Engine. With that being said, interpol_kun should be slapped for their comment as well as LiterallyJeff. Everyone else, thanks for responding to the question correctly.