Forum rules - please read before posting.

Direct Control Tank Movement How to Back Animation and prevent from moving forward? and sound

edited April 2018 in Technical Q&A
Hello,

I have all my turn/walk/run animations based on Speed, I recently changed to Tank movement in order to allow the player to turn in spot,

However when the player goes backwards

1. Player goes back and when he lets go of back movement, the player moves 1-2 steps forward automatically, how can this be prevented so it comes to a complete halt? (Also its backwards movement speed is way too much, how to reduce?)

2. How do I know use the Walk animation (can set it as reversed) for when the player is moving backwards to play that animation, I checked the Animator and it is not based on Speed?

3. My movement blend tree was setup as 1D for Speed, however now I have Turn that should also play the walk animation, how can I include that within? (More like Unity question, maybe I can add an extra parameter Turn? I just cant figure out how), what is the best way?

4. When the player is now turning left/right there is no footstep sounds played, how to enable walk footsteps sounds when turning,

Thank you

Comments

  • NOTE: I think I figured out the walk animations, I changed it to 2D Freeform Cartesian and added 2 more Walk animations, to -1x and +1x for the Turn float, seems to be working good.
    • Player goes back and when he lets go of back movement, the player moves 1-2 steps forward automatically, how can this be prevented so it comes to a complete halt? (Also its backwards movement speed is way too much, how to reduce?)
    AC/Unity version numbers, please.  Does the step-forward behaviour occur when using Tin Pot?  Does your own character rely on Root Motion?

    I will look into providing a field to control backward movement speed.

    • How do I know use the Walk animation (can set it as reversed) for when the player is moving backwards to play that animation, I checked the Animator and it is not based on Speed?
    You might have to move the backward animation out of your blendtree, and have it transition to it if the movespeed is negative.  As this involves the Animator, however, this is not a question for AC.

    • When the player is now turning left/right there is no footstep sounds played, how to enable walk footsteps sounds when turning,
    You can use Animation events within your turn left/right animations, to call the Footstep Sounds component's PlayFootstep method.  See the "Footstep sounds" chapter in the Manual for more.
  • edited April 2018
    Move speed float is set to Speed, in the animator when going backwards the Speed float does not go in negative, it stays at 0, when moving forward it only then increases.

    When you refer the movespeed negative, is that the float you are referring to? If so why does it stay at 0 when going backwards?

    Thank you for the rest,  looking forward to the field to control backward movement speed.

    AC: 1.62.5
    Unity: 2017.3.0f3

    I have Input Magnitude effects speed checked on, (on your demo I left it unchecked)
    Player Mecanim, Automatic,
    No root motion on animator component.


    Re-imported your asset just now (to include Demo)

    Loaded the Demo Asset file (ManagerPackage), changed to Direct / Tank,

    Went backwards few steps, goes forward 1 step, same as with my own Scene.

    Is this a particular bug on my end or?

    Thanks


    • When you refer the movespeed negative, is that the float you are referring to? If so why does it stay at 0 when going backwards?
    It shouldn't - does it do that for Tin Pot as well?

    • Went backwards few steps, goes forward 1 step, same as with my own Scene.
    Bug recreated, thanks.
  • Unsure if I've changed anything since, besides swapping between the Demo and back to Mine, the Speed float is now going to negative and all seems to work for the animation part of it.

    I'll just await for the new update to fix the bug and the speed limitation on backwards movement,

    Could I also request another option, to reverse when moving backwards and turning?

    For example, if I am moving back and left at the moment the character will go towards the right of the screen while moving backwards, I'd like to be able to reverse that, and leave it as an option to the player, that way if the player is moving back and left it goes that way.

    Thank you
  • My goodness,

    I just went to check updates etc, and you've already fixed the bug, added the backwards speed and updated with Unity...

    Lightning speed,

    Please let me know if the reverse backwards turning is possible,

    Thank you very much for this amazing support.
  • The reverse-turning is a little unique, so I'd say this is best left to a custom script that remaps the inputs.  It's pretty simple though - inputs can be overridden using delegates (see the "Remapping inputs" chapter of the Manual).

    http://pasteall.org/945174/csharp
  • Thank you! You are great

    Could you help me yet again with that script, to add another smart part where:

    If player was Running (AC.KickStarter.playerMovement.??) and is reversing, limit to walk only, then when the player stops reversing toggle back to normal, in running mode.

    Unless it was walking then no change necessary but do not allow to run backwards?





  • I am extremely grateful,

    If I could leave another review on your asset store I would,

    Thank you
  • edited May 2018
    Sorry to be a pain in the rear, however the script now does not allow the player to run?

    I tried changing it from Free to NoChange but that makes it run continually unless reversing :/
  • NoChange will do just that - leave it as Free.

    It works for me fine, though.  It may be to do with the Script Execution Order, which can vary from machine to machine unless specifically defined.

    Try altering the script's execution order relative to AC's StateHandler script (before or after, I'm not sure which'll work)
  • I fiddled with it and moved the ReverseTank script around, unfamiliar with what it all means and may be doing it wrong?

    However still same issue,

    I put a Debug to show the runLock in the LateUpdate, and when the player moves forward it goes back to Free,

    However the speed itself is limited to 1.5 which is my walk speed, at first it goes up to 1.8 but quickly goes back to 1.5,

    Could this have something to do with the Reverse speed factor?
    I also added runSpeedScale in the Debug and it remains at constant 4f which is my running speed,

    However in the Animator and the actual player running is at 1.5 regardless of what the Debug says
  • As it works no problem for me, it's hard to say - I can only really speculate.  What is your Reverse speed factor now set to?

    The runSpeedScale won't change - it's used to scale the speed when running, and isn't always the actual speed the player'll take.

    If the speed itself is limited to 1.5, doesn't that mean running is not occuring?  What is the speed difference when backward-walking vs backward-running?

    You could also try changing the runSpeedScale when reversing, so that the player can technically "run" backward, but it wouldn't be visibly apparent:

    http://pasteall.org/946254/csharp

    Thinking about it, that could've probably enabled backward-speed control in the first place...
  • The factor I set it to 0.7,

    Right now with the new script the walk back and running speed is both at 1, only difference is when its running backwards even though it is speed of 1 it is playing the running footsounds,

    I am going to continue using the new script, I will do Animation events as you suggested for when turning and hopefully figure out the hack to tell the footsteps when reversing it is only walking.

    Thank you for all your help, one day I will make sense out of all this C# and annoy you less,

    Have a great day.
  • Hi Chris,

    It seems that the player will remember its Reverse settings if they went backwards and not forward yet, therefore when just turning the InputAxes are not back to normal.

    I did this: if (axisName == "Horizontal" && Input.GetKey(KeyCode.S))

    Is this the right thing to do?

    That way only when the player is holding the "back" button it reverses, when not it is back to normal,



  • If it works, it works.  I'd tweak it so that it reads the Vertical axis though, so you can remap / use the arrow keys as well:

    if (axisName == "Horizontal" && Input.GetAxis ("Vertical") < 0f)
  • Thank you Chris,

    That works as intended to.
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.