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

Composite Collider 2D causing bug in animations

Discussion in '2D' started by EduFoqsi, Jun 22, 2019.

  1. EduFoqsi

    EduFoqsi

    Joined:
    Jun 21, 2019
    Posts:
    4
    So, i was learning from a youtuber how to make a 2D game, and when creating the 2D pallete, collider and etc, he said to add composite collider 2D to stop the issue of walking and triggering the jump animation on the "borders" of the tilemap collider. But when i add the composite collider 2D, my Y keeps changing even when im going to left or right. Without composite, my Y changes only on the "borders" of the tilemap collider. And, when my Y changes, it's trigger the jump animation, so the player "walk" with the jump animation. I don't know what to do, please help
    Why composite collider makes the Y changes?

    (im new at unity and progamming, and also brazilian, so sorry for the bad english and knowledge)
    (in the image, the red lines are the "borders" i was talking about)
     

    Attached Files:

    vicvighi and IsaacAM517 like this.
  2. danmichson

    danmichson

    Joined:
    Jul 7, 2019
    Posts:
    1
    Encountered the same problem, and while we were not able to get rid of the Y movement we managed to create a "workaround" that could work for you as well. (Depends on the way your animation state machine is set up)
    We checked originally if the player had a horizontal speed that is greater than 0 and if so switched to the jump animation, and simply changed that to 0.1 / -0.1 for the upwards and downwards animation parts of the jump.
    As the composite collider only has a very small affect, this solved the problem for us.
    (and as we always move faster than this small value our jump never "glitches" back into the normal idle animation throughout the jump.)
    Hope this could help you, even if it is not a really clean fix^^
     
    vicvighi likes this.
  3. vicvighi

    vicvighi

    Joined:
    Sep 3, 2018
    Posts:
    1
    Thanks, i encountered the same problem too, but my was not animation, the jump was triggered with the y velocity. Y velocity was modified with the composite collider 2D, your question give me some light, now the trigger is a bool "is grounded" and the jump is working fine s2