Forum rules - please read before posting.

Mechanic Parameter Turn Float

Hi everyone,

sorry if this is a noob question, but I'm having trouble understanding the Player Mecanim Parameters for Turn.

And btw, I've read the manual and the excellent post about using MoveSpeed as a float parameter. No problem there.

But what does the controller look like for my turn animations?

I have created Blend Trees with animations for Idle turn Left and Idle Turn Right where the mechanim can rotate 45, 90, 135 and 180 degrees. Same for Walk and Run.

I have my float parameter called Angle. 

I have created the appropriate transitions between my Idle state and Idle Turn Left and Idle Turn Right. Same for walk and run.

But then what? Feels like I'm missing a tiny piece of the puzzle. Is it in the thresholds values? Or in the transitions between states?








 

Comments

  • edited October 2016
    I have the same issue. When i move the mouse left or right, (first Person) to turn the character, the TurnFloat Parameter stays at 0 all the time. It does not change, and the animations do not trigger because the TurnFloat is 0.

    I wanted to post this issue, but it tells me i need to wait for Post Approval. 
  • edited October 2016
    The turn float parameter is set to the result of the Char's GetTurnFloat() function.  It's not an absolute angle, but rather the amount of turning the character is doing at that particular moment (from negative "Turn speed" to positive "Turn speed".

    @djeby: The turn float parameter is not set when using First Person movement, but I will look to see if can be added in.
  • @chrisIceBox Thanks a lot. I appreciate it.
  • Hmm still a bit confused by it all... I know this isn't a Unity support forum so I understand if this is asking too much, but is there any chance we could get a tutorial on setting up a complete Mecanim character within AC? One that includes Vertical movement and turn floats too.

    Something along the lines of 

    I'm only asking because I've been browsing the forums all morning and it seems a few people are confused by the way AC handles motion. 
  • In fact, I'd go as far as offering my services to write said tutorial! I'm a technical writer by trade so if anyone could provide me with a complete AC player prefab + animator controller, I'd be happy to join the dots and write something for the wiki
  • Thank you, that's generous of you.  AC's Mecanim approach is really to control parameters of your choice, leaving what you do with them down to your specific needs - so a "one-size-fits-all" isn't too feasible.  However, here's an image of my own Mecanim-based character's Blend Tree:

    image

    The "Forward" and "Turn" float parameters are entered into the Player's Inspector, and the animtion's are the ones that come in Unity's Standard Assets.  The animations rely on root motion, so Apply Root Motion also has to be checked in the Animator component.

  • Thanks for that, it clears so many questions. My confusion was in mistaking turn for angle. 

    So am I right in assuming you'd need to call the Quaternion AC.Char.GetTargetRotation () to get more control over character movement?

    If so, how easy is it to do? (in the meantime I'll ask a dev friend to look at the script for me so I can write a step by step guide)
  • GetTargetRotation will return the character's intended rotation as a Quaternion (see the scripting guide entry).  Whether or not that's what you want to use will depend on your own needs, but that coupled with the character's actual rotation should be enough to do whatever you want with.

    I've found that using the "Turn float" parameter is enough for my own needs, though.  The general principle in AC's Mecanim implementation over Legacy is that there isn't really a "one-size-fits-all" approach - rather, it gives you the tools to do with what you want.  The added complexity comes with the greater flexibility in what you end up with.
  • Still working on this. Haven't tried to enable GetTargetRotation, but there might be a simpler solution:

    Is there any way to enable the bool isTurningBeforeWalking only when the character is at a standstill? 

    In case anyone else is wondering why, here is what I'm trying to achieve for my character:

    - uses root motion to turn
    - when still, uses a turn animation before going into the walk cycle
    - when walking, uses a motion blend for turning 

    When "Turn before walking" is selected, the character goes through the "turning" animation as expected, but also pauses to turn when walking. 





  • I'm only thinking theoretically here, but maybe you could try a script that turns the "Turn before walking" checkbox on automatically only when the character has been still for a set time (even >0.1s should be enough).  You can then turn it off once they begin walking until they stop again.
  • Thanks Chris, modifying the line 1660 of Char.Cs worked like a charm

    if(moveSpeed<0.1){isTurningBeforeWalking = true;}else{isTurningBeforeWalking = false;}

    However, sorry if this is dragging on, but I still didn't manage to get complete control of the "turn on the spot" animations using root motion. 

    What seems to happen is that Unity recalculates the "Turn" value while the character is turning. I have all the turn on the spot animations setup in a blend tree. But it always triggers the same 45° turn animation. 

    Playing with the Turn speed value in the movement settings of the AC player script seems to be the key, but I can't get it spot on. 

    At this point I'm only relying on a 45° turn on the spot animation. The root motion turning slider is turned to about 0.3 and that works perfectly for my needs. It triggers a turn animation and AC makes the character spin on itself too.

    Just wondering if anyone has had more luck with these pesky turns :)



  • You should be able to move that to a separate script so that you can update AC without having to redo the change.

    The BlendTree should update itself if the Turn value changes mid-turn.  Are you using a 2D BlendTree.  Here's one I made for my own project, and it's always played OK for me:

    image
  • Mind you, I'm using root motion for movement but not for turning.  Do the correct animations play if you reduce Root motion turning to zero?
  • Thanks so much for the patience and responses. Think I finally cracked it.

    I am now only using root motion (slider turned all the way to 1). "Turn before walking" is not selected.

    -  the MoveSpeed parameter would sometimes be called before the turn float. So the character would start walking forward instead of turning on the spot.

    - this can be solved by increasing the Turn speed value

    - However, you also need to adjust the threshold of the Turn animations to match the turn speed value. So if that speed value is 3, your 180L animation should be at -3. The 180R should be at 3.

    Hope this makes sense and it can help others with their animation controllers!



  • Hey Chris, is there is a way to get this controller? I am having the same issue - right now my game has almost everything that I wanted to implement in it, except for my character controller which is moving like a robot and not realistic. I want him to have some nice moves, blends, turns, smooth start walk, end walk etc. I bought several collections of animations and now I need a good controller to use all this together. It seems that your controller is really good. But I guess I am not able to repeat what you have show in your screenshot (controllers is not what I understand good enough.).

  • I only used what forums and tutorials on the Unity website covered. The locomotion aspect of that controller is little more than what's in the screenshot.

    https://iceboxstudios.co.uk/stuff/Humanoid.unitypackage

  • Thank you Chris:)

  • I know this is an old thread, but by any chance do you still have the Humanoid.unitypackage @ChrisIceBox ? I'm struggling with a very similar issue.

  • It's very similar to the "ThirdPersonAnimatorController" asset that comes with Unity's Standard Assets package. Have a look there - it should be chiefly the same.

  • Thanks so much!

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.