Forum rules - please read before posting.

Need Help With Animation Rotation

Hi there everyone! I am new to the Adventure Creator development community!
I have recently started development on my dream game! But have hit one major road block. My character seems to work perfectly when it doesn't have animations, it faces and walks the current direction, however upon adding in my animation controller with my animations, the character's front is now changed to his back. If you get what I mean. Basically, when I apply the animation controller, the characters walking backwards when I try to walk forwards. And when it faces something like an npc, it turns it back to that NPC! I know this may be a dumb question but I would love some help!

Comments

  • Welcome to the community, @wendellmeset.

    This is for a 3D game, I take it?

    Check that your 3D model is "front facing". Place it in your scene, set its Transform component's Rotation values to (0,0,0), and check which direction they face. They should face along the +Z axis.

    You can compare your model with that of the 3D Demo's Tin Pot, by dragging him into the scene as well. His model can be found in /Assets/AdventureCreator/Demo/Models/Chars/Robot/Robot.

    You'll also need to make sure that the character continues to face this direction when playing their "standard" animations, i.e. idle, walk, run etc. How you correct these if not will depend on where you're getting them from, and playing them in-game. Are you using Root Motion for this, and are you creating the animations in Unity or importing them?

    This sounds like it's a more general Unity animation issue, but if you'd like to share screenshots hosted on e.g. imgur.com, paste links to them here and I'll try to spot what's wrong.

  • Wow, some of the fastest support ever, specially for a unity asset. Props to you.

    Anyways, back to the problem at hand!

    Yes this is a 3D game. Anyways, How would I check the direction they face, I am extremely new to Adventure creator and unity as a whole. Anyways, I am not using root motion, however here is a break down of the steps I used to get the model and animations into unity:

    • Downloaded and Opened Blockbench
    • Created My Model
    • Created My Animations
    • Used a Blockbench Model Importer Unity Plugin (https://github.com/lexize/Blockbench-Model-Importer)
    • Placed The Model
    • Do to the model's front being its textured back, I created an empty game object.
    • Rotated the game object so it would face correctly.
    • Put all the models from inside the imported original model into new game object.
    • At this point the model worked fine without any animations.
    • Applied animations for walk, run, and idle using Blend tree.
    • At this point the model starts walking backwards!

    I am guessing it has something to do with the Game object starting out entirely backwards. As far as I know and have searched, BlockBench currently has no feature to change to Z forward, instead of Z backwards! Is there a way to fix this directly in unity?

  • edited March 2023

    Thanks for the details. I'm not familiar with BlockBench, but it does sound like an axis issue.

    Which GameObject have you attached the Animator to? The same child object as the model, or the character's root? If you open up the Animation Clip in Unity's Animation window, are the Rotation values of its GameObject being keyed?

    At runtime, try selecting the GameObject child (the object with the model) and see if you can update the Transform's Rotation on the Y axis manually. If you can, it sounds like rotating it by 180 degrees would cause them to face the right way - in which case, making the same change to the object outside of Play mode may be enough.

    Otherwise, you could feasibly create another child GameObject in between the root object and the model child, and control that object's rotation manually instead.

  • I have attempted controlling child gameobject rotation values. However I would I apply the character controller for the animations, as the animations do not play if they are not on the main object with the parts inside of it itself!

    Sorry for the late response!

  • Could you try fixing it on your end and then directing me. This is the blockbench model: https://www.mediafire.com/file/k2wbx8idc09de3q/22mod2el.bbmodel2.bbmodel/file

    And I have already posted the unity plugin/asset used to import it, in order to import the material you will have to export the blockbench model into fbx from blockbench itself, then extract the texture, convert to material, and then use that material for the model itself. To fix the blurry textures change bilinear texture to the other one, I cant remember exactly. Reason I dont import FBX by itself is cause it does not import the animations. Which is why I use the blockbench importer plugin!

  • I managed to fix it by rotating every individual body part 180 degrees to the back! This worked because my animations are not one way, and it does not matter which direction they are playing from. However for future reference, how would I fix the problem for animations that need model to face a certain direction?

  • The main thing to keep in mind is that your animations should all refer the same direction as "front-facing". Idle, walk, run etc should all point in the same direction (+Z ideally, otherwise child rotations as mentioned above would be necessary).

    If the animations are set up according to this axis, then they should face the front in-game. This doesn't mean that they'll be locked to that direction, mind - the character can still turn. You can use the Character: Face object or Character: Face direction Actions to have them face a secific direction at runtime.

    If you'd like to share some screenshots of your character within the scene, I can try to offer more specific advice.

    I have attempted controlling child gameobject rotation values. However I would I apply the character controller for the animations, as the animations do not play if they are not on the main object with the parts inside of it itself!

    In this case, you might be able to move the Animator component along with it. It sounds like a Hierarchy similar to this would allow for it:

    -> Root GameObject (with Player component)
    --> Child #1 (rotate this manually in Edit mode to have face the right direction)
    ---> Child #2 (with Animator and body parts)

  • For the child 2 with animator. How would I make it animate during walking and running when the parent has all the player components for this. Also, would I use child 2 for the animation in the timeline, or root, and if so, how?
  • For the child 2 with animator. How would I make it animate during walking and running when the parent has all the player components for this.

    The Animator doesn't need to be on the root object. You can assign which specific Animator component the character relies on by assigning it in the Player/NPC component's Animator (optional) field. The parameter fields set above it will still be applied to this Animator, independent of its location.

    Also, would I use child 2 for the animation in the timeline, or root, and if so, how?

    You'd typically animate the root for position/rotation changes, and the model child object for animation clips such as picking up items etc.

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.