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

Resolved Root Motion constantly walks/runs through colliders.

Discussion in 'Scripting' started by TabuuForteAkugun, Nov 24, 2021.

  1. TabuuForteAkugun

    TabuuForteAkugun

    Joined:
    Sep 28, 2015
    Posts:
    56
    EDIT: Resolved it myself! I was checking the wrong axis for wall collisions. Make sure not to mix X and Y axes when coding collisions LOL. Also Tabuu Tip: Use OnAnimatorMove when using Root Motion. It helps.

    Hi!

    First off, I want to say thanks to everyone who helped me with my frame-timing issues thread. I think I've figured it out now, so we're good there.

    Now another issue I have is with walking/running/attacking.

    I just recently decided to convert my whole setup to Root Motion to move my character around: for walking and running and some attacks that move the whole body. Sadly, I get a fairly consistent issue: Root Motion decides to just screw with my collision detection: Ground and ceiling collisions work A-1. But walls are an issue. At certain speeds and instances, the Root Motion will almost 100% of the time clip right through all walls in my scene. I'm making a 2.5D platform fighter, as mentioned, and I don't want walls to be "air".

    I read somewhere that Root Motion is applied via Transform.Translate() behind the scenes. My setup and custom physics controller also uses Transform.Translate() by default with Raycasting for collision detection, but even that doesn't work. I tried a few hacky solutions I could come up with, like freezing the Z velocity when against a wall, but either a) it still clips or b) it gets stuck on the wall. I even tried to visualize my collision booleans on screen and with walls it sometimes won't even register as a collision. And yes, I checked to make sure it was a collider and not a Trigger.

    I would really appreciate help on this, as tutorials and information in general about Root Motion is rare.

    Thanks!
     
    Last edited: Nov 28, 2021
  2. TabuuForteAkugun

    TabuuForteAkugun

    Joined:
    Sep 28, 2015
    Posts:
    56
    Thanks for reading, but it took me WEEKS to figure out I was checking for collisions on the WRONG AXIS.

    I was checking movement on the X axis when I should've been checking on Z.

    Moral of the story: don't be like me and get the correct axis when moving ^_^