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

How to make Animation work with Physics or Colliders

Discussion in 'Animation' started by zackyang421, Nov 11, 2021.

  1. zackyang421

    zackyang421

    Joined:
    Oct 13, 2021
    Posts:
    13
    Hello There:

    My Enemy characters have a backward animation which would make them backwards slightly, and an attack animation which would make them move forward slightly. So when the enemies have been attacked near the walls or they are trying to attack characters near walls, the animation would let them just go through walls.

    But I want when the animation collides with walls or other colliders, it can just stop there without keep moving through those colliders, so how should I fix that?
     
  2. krunkeriogm

    krunkeriogm

    Joined:
    Nov 12, 2021
    Posts:
    1
    I'm beginner at Unity.

    I downloaded asset with animations to check how animation controller and ragdoll is working. And then, I noticed, that when animation is playing, object stops reacting on physics and ragdoll, and when you switch off animation controller - physics starts working, as well as ragdoll.
     
  3. KalOBrien

    KalOBrien

    Unity Technologies

    Joined:
    Apr 20, 2021
    Posts:
    89
    You need to do a bit more to get physics working with animated objects. Usually animation frames take priority.
    Some good content to understand it.


    With regards to animations moving through objects. A collider that triggers a "Knockback" animation that causes the gameobjects to move back based on the forward position.
     
  4. zackyang421

    zackyang421

    Joined:
    Oct 13, 2021
    Posts:
    13
    Thanks buddy! That video helps me a lot!
     
    KalOBrien likes this.