Search Unity

Detecting Collision for DanmakU?

Discussion in 'Physics' started by VFranklin, Jan 11, 2020.

  1. VFranklin

    VFranklin

    Joined:
    Jul 26, 2017
    Posts:
    48
    Hi,

    I'm using the DanmakU Package from https://github.com/james7132/DanmakU .
    It's pretty good, but I have no idea how to set up collision.

    I added a User Layer called Bullet and have this attached to the player
    Code (CSharp):
    1. void OnCollisionEnter2D(Collision2D col)
    2.     {
    3.      
    4.         if (col.gameObject.layer == 12)
    5.         {
    6.              Debug.Log("I'VE BEEN HIT UGHHH");
    7.         }
    8. }
    ... but it's not working.
    I attached an img of the Physics layers.

    Is there maybe a problem with the way I set up the Physics Layers Collision?
    ---
    I think the emitter is spawning Danmaku Prefabs so I attacked a Circle Collider but nothing's happening.

    Any help greatly appreciated! Thank you.
     

    Attached Files:

    Last edited: Jan 12, 2020
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    Maybe that you're using the LayerCollisionMatrix for 3D physics not 2D physics? The image you show above is from the 3D physics settings.
     
    VFranklin likes this.
  3. VFranklin

    VFranklin

    Joined:
    Jul 26, 2017
    Posts:
    48
    I've never used the LayerCollisionMatrix before. Don't quite understasnd why its only for 3D. Any resources you recommend? (https://docs.unity3d.com/Manual/LayerBasedCollision.html)

    If the matrix is for collision between two objects and their layers why is it for 3D?

    Thank you.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    The one you show in your image is for 3D because you went into the Project Settings and selected Physics. If you look, there are separate project settings for Physics 2D next to it in the list. Use those settings there.

    ProjectSettings