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

How do i add "Wallbangs" to my game?

Discussion in '2D' started by ZGMATT, Apr 20, 2017.

  1. ZGMATT

    ZGMATT

    Joined:
    Mar 9, 2017
    Posts:
    4
    i was wondering if anyone knew of any ways i could go about having "wallbangs" in my 2d shooter?
     
  2. Zephus

    Zephus

    Joined:
    May 25, 2015
    Posts:
    356
    You felt the need to put quotation marks around that word, so you obviously know it's not clear what you mean. And then you don't even elaborate. I have no idea what you're talking about.
     
    LaneFox and theANMATOR2b like this.
  3. clorxwetwipe

    clorxwetwipe

    Joined:
    Sep 28, 2015
    Posts:
    3
    Do you mean wallbangs from CS:GO? Like shooting through a wall?
     
  4. ZGMATT

    ZGMATT

    Joined:
    Mar 9, 2017
    Posts:
    4
    exactly
     
  5. SK83RJOSH

    SK83RJOSH

    Joined:
    May 11, 2014
    Posts:
    6
    This really depends on how your firing mechanics are setup. If you're using raycasts for projectiles this is pretty simple, if you're using physically simulated bodies it's a bit a bit trickier. Both solutions would require you to raycast forward, find a collision with a wall, then determine the depth of the wall and apply specific logic to attenuate the damage / speed / other properties of your bullet.

    Here's a video that has some very good visualizations of how this works in games like CS:GO and Arma III:



    I know those are 3D examples, but the implementation would be fairly similar in a 2D game. Unfortunately I can't provide you with any links to specific tutorials since I don't know of any off hand and I don't know what your specific use case / implementation is.