Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Walk/Run/Sneak Button

Discussion in 'Animation' started by kingmujo, Aug 7, 2017.

  1. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
    Hello everybody,

    first of all sorry for my bad english, i am from Germany.

    Im a beginner with Unity and I started my first Project.
    Its a Ball with legs, walking automatically on the same spot.
    my wish is to change the speed of that walking by clicking on three buttons
    1. walk
    2. run
    3. sneak
    its not only the speed its also the movement. i want a smooth movement from walk-run-sneak-...
    i did three animations for those stats.

    my problem now is when i press on run, it instantly starts to run but not smooth ( i mean the physics )

    i would be thankful for any help

    Mujo
     
  2. RevoltingProductions

    RevoltingProductions

    Joined:
    May 2, 2017
    Posts:
    28
    You will need to post your code and animations if applicable.
     
    kingmujo likes this.
  3. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    6,385
    use mecanim state machine with transitions.
     
    kingmujo likes this.
  4. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
    i must use it via blend tree ...

    my task is to create a walking character ... this character is walking in normal speed at beginning ... now my task is create 3 buttons : walk, run, sneak ...

    by clicking on the button run my character must stark running ...
    so far so good ... i have 3 animations walk, run,sneak ... but when my character is walking and i press the run button, my character starts running instantly ... it doesnt look smooth ...

    maybe using blend tree ?
     
  5. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    6,385
    Their is an option on the transition called 'has exit time'. Change that to have the current animation complete and transition into the next animation.
    If the setting for has exit time currently is checked, uncheck it.
    Also look up 'has exit time' in the documentation for more information. ;)
     
  6. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
    i did that already .. :(
    still doesnt work :(

    maybe the problem is my button ?
    i activate the run on my run button by OnClick() then Animator.Play and the run animations name ...
     
  7. RevoltingProductions

    RevoltingProductions

    Joined:
    May 2, 2017
    Posts:
    28
    It may be prudent to use a lerp function for your input too. Again, post your code and blendtrees for better help.
     
  8. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
  9. RevoltingProductions

    RevoltingProductions

    Joined:
    May 2, 2017
    Posts:
    28
    You have in interruption toggle on. This means that you are allowing the input to interrupt the transition and go into the next state. Uncheck that. Although it seems intuitive to use that feature, you really only want to use it on very particular circumstances for instance a jump where you want to force a very rapid transition. Even then interruptions can be problematic because they can affect the logic, like making a character jump before they have properly landed, stuff like that.

    Try that and let me know.

    Also, you only have one parameter called blend. I'm not sure how you are using that, but typically that parameter would be called speed and you would decide which state the character should transition to by the speed of the input.

    For the transition that you have selected the blend input to satisfy it is greater than 0. I'm guessing that the transition to sneak is if blend is less than 0 and that straight walking is 0 and further that your buttons are what change the value for blend. I don't know because you don't have your code represented but how you set that up is crucial.
     
    Last edited: Aug 10, 2017
    theANMATOR2b likes this.
  10. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
    first of all thank u so much for helping me !!!

    by interrupt toggle u mean = interruption source ? I've turned that off now ...

    since now i didn't use blend ... it appeared automatically

    and i didn't use a code ... u mean code my c script ? i didn't use one ...
     
  11. RevoltingProductions

    RevoltingProductions

    Joined:
    May 2, 2017
    Posts:
    28
    Sure, no problem :).

    Yes, interruption source should be set to none.

    Okay. So now we are getting somewhere. Yes, your C# script, the code you use to take input and set the animators parameters. If you don't have any code, then you have no behavior other than the initial state. Are you sure you have no code? You are definitely going to need it.

    Are you creating your own character and animations?

    You may need to take a few hours and review this:

    https://unity3d.com/learn/tutorials/topics/animation
     
  12. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
    the character and the table i got it from my class ...
    my mission is to add 3 buttons with these three stats walk run sneak ...
    i have no script ...
    i really need one ? can i do it without script ?
    here are some possibilities i get when i click on my "onClick()" menu on my button:
    1: https://www.imagebanana.com/s/780/5O8ANs6d.html
    2: https://www.imagebanana.com/s/780/zEg5e39z.html
    3: https://www.imagebanana.com/s/780/Lg2OwzLj.html
    4: https://www.imagebanana.com/s/780/iWkqgW1i.html

    as u can see .. i use the Animator.Play(string) option ... in that string i write the name of the Animation ... for example "run" ...
     
  13. RevoltingProductions

    RevoltingProductions

    Joined:
    May 2, 2017
    Posts:
    28
  14. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
    i almost did it the same ...
    i have the play animator ... when i press my buttons it changes to walk run and sneak ... my problem is that the transition from walk-run isn't smooth ... it jumps from walk to run and so on ..
     
  15. RevoltingProductions

    RevoltingProductions

    Joined:
    May 2, 2017
    Posts:
    28
    Your transitions seem like they should be soft since you have plenty of overlap between the states.. You could extend the transition out so that is the entire length of the run cycle, but it sounds like that may not have an effect either. You should record your screen with the error and or post your code.
     
  16. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
    i upload u a video ...
    in the video u can see if i click on tablestop... my table stops instantly in the same position where i start my animation for stop ... i doesnt stop on the position where it was in the moment i stopped ...

    same for my run/walk ... when i click on run .. it starts instantly ... :(


     
  17. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
    and i want it like this ...

     
  18. RevoltingProductions

    RevoltingProductions

    Joined:
    May 2, 2017
    Posts:
    28
    Okay, so... you must have code to have created this. I need to see it. I can't help you without it. C# code. You have it, post it.

    If you are confused about where your code resides then know that it is more than likely in the hierarchy of the asset that is being animated, probably on the top most object in the asset. If you didn't save it to a particular directory path then it is in the root of your project.

    As far as the table top goes, did you create that rotation animation at the asset level? Which is to say in another program, with the animation included in the export. Or did you create it as a curve in unity? Or is it driven by code? BTW, in the future you don't want to introduce a second problem without having solved the first. ;)
     
    Last edited: Aug 12, 2017 at 1:22 AM
    theANMATOR2b likes this.
  19. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
    i really don't have a script ...
    i searched the whole folder ... didn't finde anything ...

    i created 3 animation ... 1 turning left table, 1 turning right table and 1 standing still table ... put them together in animation controller called 'Table' put that controller on my table object ... linked the 3 animation to the 3 buttons ... thats all i have done ... nothing scripted with c ...
     
  20. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    6,385
    How did you do this? This part is normally done in code or a visual scripter. This is what @RevoltingProductions is talking about.
     
  21. kingmujo

    kingmujo

    Joined:
    Aug 7, 2017
    Posts:
    13
    i really didn't write any codes ...
    i chose table as game object in my onClick() Menu ... then there are functions i can chose ... for example i take "Animation" ... after i chose that there comes another Menu called "Play(string)" ... and in that string i write the Name of the animations ... for example TableStop ...