Forum rules - please read before posting.

first person strafe?

edited September 2015 in Technical Q&A
Can't seem to find a control settings that allows for this, is it supported? All I get in every method just uses A/D for turning, which isn't really a good use of controls with mouselook already on in first person.

This is in mecanim. I have animations for the strafe as well... (actually using this very simple example to try to get it to work

but I think I need a movement parameter condition to plug into that I don't have access to?


  • edited September 2015
    Ok, I figured out a way around this via playmaker, since you can control mecanim via the parameters there.

    After you've created a HSpeed float in the Animator window and attached left/right strafing animations, make a new Playmaker FSM:

    state 1:

    1. find game object with tag player, store in player game object variable
    2. get key down for the a or d key

    state 2:
    1. get Animator float, variable: player, parameter: HSpeed, result:HSpeed variable
    2. Float Add - HSpeed, add 0.1 (or whatever, and must be -0.1 for opposite dir), every frame
    3. Set Animator float, parameter: HSpeed, value: HSpeed, every frame
    4. get key up, a or d, event: finished

    state 3:

    1. Set Animator Float, player, parameter:HSpeed, Value: 0.

    Then connect state 3 finish to state 1 and it's good to go, assuming you have the strafing animations in the project and they're set to condition HSpeed in the Animator.

    Of course you need to get all the little things right in your animator, like not check use exit time and so forth, but works fine. :)

  • In your Settings Manager, look for the "Turning type" underneath "Movement settings".  If set to "Relative To Camera", you'll be able to strafe.
  • edited October 2015
    When I set it to that, the 'w''a''d' keys all generate forward movement only

    There are just transitions on the animator right now though, I have to build a blend tree anyway so once I do I'll check if that would work with just AC controlling it... because that might help.
  • Strange.  And those keys are mapped to your Horizontal and Vertical axes in Unity's Input manager?

    You can temporarily assign Tin Pot (/Assets/AdventureCreator/Demo/Resources) as your Player prefab - he's been set up to also work with First Person movement for testing.  See if you can get it working with that prefab first.
  • edited October 2015
    Well I tried setting up my controller in new scene and it does the same thing. Tin Pot can strafe with mecanim on, but there's no animator for Tin Pot so it's not the same thing. But my character with movement animator can only move if the anims are triggered, and AC can't trigger the parameter I've used (I don't think)

    In other words with mecanim the animations are applying movement info so the animations must actually strafe left or right. Then you can set a mecanim parameter for that horizontal axis and set the a/d keys to work with it.

    That's what I already did in my project with playmaker.

    If you want I can zip up the scene showing just the problem to look at.
  • AC's first person mode assumes that all control goes through script - not the animation.  See if it works after your disable "Root motion" in the Animator Controller.
  •  "AC's first person mode assumes that all control goes through script -
    not the animation.  See if it works after your disable "Root motion" in
    the Animator Controller."

    Yep you found it, that was definitely why it wouldn't strafe in mecanim!

    I might go that route. It does take away the more 'heavy' physicsy-feel that you get with root motion on but root motion has other very tricky issues to work with I would still have to sort out.It's still a toss up. There's a lot of pros and cons to both.

    Character controller in general is a pain in the butt area to be messing with and I wish I was as smart enough to whip up something like this.  Clamped feet, collision pushback, slopes, stairs... it's so cool!

  • edited October 2015
    Ok here's the finale of my ridiculous experiments with the first person movement:

    stuck to AC first person, turned off root motion, added changing footstep sounds automatically by surface, added my own running, slow walk (cutscene, stealth, admire the scenery), jumping, tribes-like flying where you can ski the terrain at high velocity if a certain item is in your possession (this is so fun :D). Rigidbody freeze when idle only applies at certain conditions on slopes, but too much slope and you slide. Added "stair step over" behavior that essentially just adds Y to rigidbody position of player if you collide with something tagged steps but not if you collide on the flat top normal... and can double as a low ledge grab by making invisible tagged boxes and so on. Overall I'm really happy except I need to think how to better blend the stepping behavior. I know I'm babbling about my work, I should probably start a dev blog.
  • Very nice!  Any video to go along with that?
  • Video! Now!  :-*
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.