Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to make this trap? PLEASE!

Discussion in '2D' started by Wly01, Oct 21, 2020.

  1. Wly01

    Wly01

    Joined:
    Oct 19, 2020
    Posts:
    4
    Hello, I have lazers that already it Works in the project, but what I want to do is a trap like one that exists in the game Super Meat Boy, in which leisure follows the player, but every time he touches (for example) an object that the player can protect himself from behind, he cuts, that is, a part of him goes away, when the player walks to a part that has no protection, the leisure gets big again and will cut depending on where to hit, and so goes successively. But I have no idea how to do
     
  2. Proxima_Centauri

    Proxima_Centauri

    Joined:
    Oct 20, 2020
    Posts:
    42
    Are leisures the eye lazer things in Hell?

    I'm not an expert but I guess the lazer has some kind of collider to hit the player. Maybe you can make the lazer detect when it collides with a gound object using tags and then set its length or range only to the point where they are colliding

    Code (CSharp):
    1. private void OnCollisionEnter2D(Collider col)
    2. {
    3.     if (col.gameObject.tag == "ground/solid block")
    4.     {
    5.         //Resize collider and sprite to hit the
    6.     }
    7. }
    Maybe something like that can help, or at least be a first approach