Forum rules - please read before posting.

Problems with animation formats in blend tree

Good afternoon everyone.

I'm having problems with animation formats in
blend tree.

I found problems with animation in the blend tree, as you can see (see photo1). I used combat example tutorial, the animations that the blend tree seems to accept only that format in the tutorial (animation Clip).

Photo 1

https://uploaddeimagens.com.br/imagens/Ismhr9M

In the second photo (see photo2)
in blend tree does not accept this type of animation ( Marked in the photo with an X ).

I imported characters and they only work with humanoid animation, but the blend tree doesn't seem to accept it.

The zombie object is in humonoid and the generic animations make it freeze, it only works for the zombie if they are humanoid animations.

Do you have a solution?

Photo 2

https://uploaddeimagens.com.br/imagens/l_c2b6k

«1

Comments

  • edited June 2021

    AC relies on Unity's built-in animation system - any restrictions regarding accepted file formats are to do with Unity, and aren't specific to AC.

    Unity's Animator system only accepts AnimationClip asset files - if you expand a model file in the Project window, it will list any animation clips that it may contain.

    If your model's Rig is set to Humanoid, then they will require animations that have been configured to use Mecanim, Unity's animation retargeting system, which allows for animations authoured with one rig to be used on a completely different rig.

    If you instead supply a Generic animation to a Humanoid rig, then animations will only play if the rig's bone names and structure match that expected by the animation file. Otherwise, it will not know what bone motion corresponds to what.

    A tutorial on this topic can be found on Unity's website here: https://learn.unity.com/project/re-targeting-and-re-using-animation

  • edited June 2021

    I managed to put the animations I wanted (animation Clip) in the blender tree.

    the zombie is set to humanoid and the animations are set to humanoid.

    However there is a crash of two animations in the blender tree, as you can see in the video I recorded, I spent the whole afternoon reviewing what could have caused the problem.

    What could be going wrong?

  • The transition between the two animations can be reduced from within the Animator window. This too, however, is not specific to AC.

    The main thing I'm seeing, though, is that the character starts hovering - this is likely to do with root motion, with the animation causing them to move upward along the Y axis.

    If so, you can prevent this in the animation's settings by baking the Y position into the pose. You can see Unity's docs on this topic here.

    Alternatively, you can disable Root Motion on your character's Animator and rely on non-root motion animations. This may give you slightly less realism so far as foot placement etc goes, but may be better for control over how the character moves.

  • I managed to put the animations I wanted (animation Clip) in the blender tree.

    the zombie is set to humanoid and the animations are set to humanoid.

    However there is a crash of two animations in the blender tree, as you can see in the video I recorded, I spent the whole afternoon reviewing what could have caused the problem.

    I meant blend tree

  • I found the problem, solved. Thanks

  • edited June 2021

    A doubt in combat example.

    I'm wanting to understand how the animation works when it takes zombie bites and it seems that there is an error in the combat example that the TakeDamage animation is not being activated. The player does not use the animation ''TakeDamage''.

    And neither the zombie when shot he has any movement of the shot damage.
    (see photo)

    photo
    https://uploaddeimagens.com.br/imagens/DJaONuk

    In the zombie I want to add one more animation besides the two present in the blend tree in this example there, the animation I want to add is the one that the zombie is on the ground eating a corpse.

    With 3 animations in the blend tree I wouldn't know how to trigger the one where it feeds from a corpse on the ground. before the player arrives with two more animations in mind.

    Because when the player goes away from the zombie, the zombie instead of staying in the ''zombieIdle'' animation he will squat down anywhere with the ''zombieBiting'' animation. I don't know how to do this in AC.

    The 3 animations are ''zombieBiting'',
    ''zombieIdle'' and
    ''zombieWalk''.

  • edited June 2021

    I'm wanting to understand how the animation works when it takes zombie bites and it seems that there is an error in the combat example that the TakeDamage animation is not being activated.

    Were the TakeDamage animations playing before you made modifications?

    The scripts in the combat example call the TakeDamage animation by name. Look for the OnTakeDamage functions in the PlayerCombat and Enemy scripts.

    If desired, you can alternatively play this animation by invoking a Trigger parameter in your Animator Controller, rather than referencing the animation directly. To do this, create a Trigger parameter named "TakeDamage", use it to transition to your desired animation, and then replace the script's CrossFadeInFixedTime function call with e.g.:

    KickStarter.player.GetAnimator ().SetTrigger ("TakeDamage");
    

    With 3 animations in the blend tree I wouldn't know how to trigger the one where it feeds from a corpse on the ground. before the player arrives with two more animations in mind.

    Blend Trees are best used when you want to change a character's motion based on e.g. their speed. For independent behaviours (such as eating or just standing), use separate states and transition between them based on e.g. an "IsEating" Bool parameter defined in your Animator Controller.

    Right-clicking a state in your Animator Controller lets you mark it as the Controller's default animation to play.

    You can alter a character Animator's parameter value using the Character: Animate Action. However, to alter one based on the Player's distance from them, it's more convenient to use script. The exampe package's Enemy script already calculates the Player's distance from each enemy in its Update function. Adding this to the end of that function will set the value of a Bool parameter named IsEating if they get too far away:

    npc.GetAnimator ().SetBool ("IsEating", playerProximity > 20f);
    

    It is important to be aware, though, that AC isn't so much involved with the enemy behaviour and combat / damage-taking side of things. The combat example package is intended as a demonstration of how custom scripting can be used to extend AC - which itself is for puzzles and non-combat games - to build new gameplay types.

    AC is still used to aid with e.g. making an enemy follow the Player, but any AI behaviour you wish to give your enemies needs to come from another source. Strong scripting knowledge is necessary to build upon the example to produce a game.

  • Were the TakeDamage animations playing before you made modifications?

    This one I didn't make any changes. I reopened this example in unity as a new project. I'm reviewing in case I accidentally corrupted some file.

  • I reopened this example in unity as a new project.

    In which versions of AC and Unity? I cannot recreate such an issue.

  • unity 2020.1.0f1 and adventure creator 1.73.5

  • edited June 2021

    I went to change the player yesterday and I didn't find what is causing this error, the shotgun and the knife when selected are at the player's feet, in the original player of combatexample this did not occur.

    I adjusted the weapons to be in his hands, on the player, however they are at the player's feet.

    .

  • I configured in player combat so that the weapons are in the hands.

    (Photos)

    https://uploaddeimagens.com.br/imagens/OS41lAI

    https://uploaddeimagens.com.br/imagens/UZX1Sjw

  • I went to change the player yesterday and I didn't find what is causing this error, the shotgun and the knife when selected are at the player's feet, in the original player of combatexample this did not occur.

    I adjusted the weapons to be in his hands, on the player, however they are at the player's feet

    I discovered the problem, the structure of the hand was deeper. The weapon is a little crooked, I'll try to solve it.

  • edited June 2021

    I couldn't straighten the shotgun in the player's hand, the gun is completely bent, I tested several parts of the hand.

  • edited June 2021

    Don't attach the weapons to your character's hand model. The root position of your "BodyGuard02_Hands" object remains at the origin of the character - it's the individual vertices of the model that change position.

    Instead, attach it to the hand bone in their rig.

    If you expand the character's Root hierarchy, you should eventually find the bone that represents the character's Left Hand bone. Add to this a new child GameObject, and assign this child to the Player Combat component's "Hold Position" field.

    You can then reposition / rotate this new GameObject, which should be a child of the Left Hand bone, to correct the weapon's position.

  • edited June 2021

    Don't attach the weapons to your character's hand model. The root position of your "BodyGuard02_Hands" object remains at the origin of the character - it's the individual vertices of the model that change position.

    Instead, attach it to the hand bone in their rig.

    If you expand the character's Root hierarchy, you should eventually find the bone that represents the character's Left Hand bone. Add to this a new child GameObject, and assign this child to the Player Combat component's "Hold Position" field.

    You can then reposition / rotate this new GameObject, which should be a child of the Left Hand bone, to correct the weapon's position.

    It worked out. thanks again.

  • edited June 2021

    **Were the TakeDamage animations playing before you made modifications?

    The scripts in the combat example call the TakeDamage animation by name. Look for the OnTakeDamage functions in the PlayerCombat and Enemy scripts.

    If desired, you can alternatively play this animation by invoking a Trigger parameter in your Animator Controller, rather than referencing the animation directly. To do this, create a Trigger parameter named "TakeDamage", use it to transition to your desired animation, and then replace the script's CrossFadeInFixedTime function call with e.g.:**


    I tried to do this and there were some errors.

    As you can see in the photos.

    Did I do it right in this script?(see photo)

    In Player combat script
    https://uploaddeimagens.com.br/imagens/R_lfQx4

    in Enemy script
    https://uploaddeimagens.com.br/imagens/VrOsVNU

    The following errors appeared.(see photo)

    https://uploaddeimagens.com.br/imagens/m-QHblc

    Assets\AdventureCreator\Downloads\Combat example\Scripts\PlayerCombat.cs(138,26): error CS1061: 'Animator' does not contain a definition for 'KickStarter' and no accessible extension method 'KickStarter' accepting a first argument of type 'Animator' could be found (are you missing a using directive or an assembly reference?)

    Assets\AdventureCreator\Downloads\Combat example\Scripts\Enemy.cs(157,14): error CS1061: 'Animator' does not contain a definition for 'KickStarter' and no accessible extension method 'KickStarter' accepting a first argument of type 'Animator' could be found (are you missing a using directive or an assembly reference?)

  • edited June 2021

    "KickStarter.player" is shorthand for the Player character - see the front page of the Scripting Guide for details.

    In PlayerCombat, replace:

    player.GetAnimator().KickStarter.player.GetAnimator().SetTrigger("TakeDamage");
    

    with:

    player.GetAnimator ().SetTrigger ("TakeDamage");
    

    In Enemy, replace:

    _animator.KickStarter.player.GetAnimator().SetTrigger ("TakeDamage");
    

    with:

    _animator.SetTrigger ("TakeDamage");
    
  • I made changes to the scripts and no errors appeared. (See photos)

    https://uploaddeimagens.com.br/imagens/0Ta-CPA

    https://uploaddeimagens.com.br/imagens/knvod6I

    I created the trigger parameter and named it TakeDamage

    However, it had no effect. (see photo)

    https://uploaddeimagens.com.br/imagens/5wp5FUw

    I recorded a video where I test the parameter in the animator, in the test it seems to work. But in zombie attacks it still doesn't have the animation.
    Animation I put a provisional test.

  • "Has Exit Time" needs to be unchecked in the Animator's Transition settings.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.