Search Unity

Adjusting blend tree parameters based on 3 dimensions (horizontal, vertical and rotation).

Discussion in 'Animation' started by WattooGaming, Jul 24, 2017.

  1. WattooGaming

    WattooGaming

    Joined:
    Jul 11, 2017
    Posts:
    6
    I'm new to unity, but I'm fairly comfortable with C# and 3D animation principals.

    I've run into a brick wall with this one though. The blend tree system is fantastic, but I'm really not sure how to solve this problem as the types only allow for operations on 1 or 2 dimensions. Perhaps this has been asked before but it's proving very difficult to find any answers by searching.

    I am coding a rather simple top-down isometric game with a orthographic camera, very similar to the "Survival Shooter" tutorial in the Unity Learn section. There is 360 of movement and 360 of aiming (rotation) which are in-dependant of each other.

    I have set up a blend tree for animation movement which is working perfect for horizontal and vertical movement, however as my camera is not following the players rotation.. once I rotate +-45 degrees the animations are not correct.

    Example.... I could rotate 180 degrees and move backwards, but then my character appears to be running forwards while moving backwards.

    The first thing I was thinking is to somehow adjust the float parameters sent to the blend tree between 0 and 1 based on the angle of rotation.. but I'm not sure if there is an easier way that I am not aware of?

    Any help would be greatly appreciated!
     

    Attached Files:

  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,334
    The common way to do this is to rotate the model in code, not in animation. You don't want to have to make a bunch of different "running forward" animations, each for what direction you're running in.
     
  3. WattooGaming

    WattooGaming

    Joined:
    Jul 11, 2017
    Posts:
    6
    Yes I figured this would be the way to go, as Unity doesn't seem to have any tools to introduce a third dimension to the blend trees.

    I was leaning towards normalising the angle value from -1 to 1 then subtracting this from the horizontal and vertical values, which is effectively "faking it" so the animation and blend tree parameters are reversed.

    Does anyone else have any techniques in mind? Open to any suggestions.
     
  4. WattooGaming

    WattooGaming

    Joined:
    Jul 11, 2017
    Posts:
    6
    Upon reflecting on my method concept... I realise that it would be pretty in-efficient as I would need to check for specific angle ranges in order to apply the modifier on either horizontal +, horizontal -, vertical +, vertical -...

    I feel like there should be a much simpler way to accomplish this...