Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

mecanim left and right animation

Discussion in 'Scripting' started by 2dgamemania, Dec 19, 2014.

  1. 2dgamemania

    2dgamemania

    Joined:
    Apr 30, 2014
    Posts:
    153
    I have just started to look at the mecanim system for use with character movement.

    I have imported a rigged character successfully and have used mecanim to move my character forward. Camera is at angle so it looks like the character is moving right (with the camera being orthographic) - all good there.

    but my problem is when i use my left key, how do i change the animation to animate and move left...?

    Basically I just want a character moving left and right
     
  2. jackdracon

    jackdracon

    Joined:
    May 7, 2011
    Posts:
    11
    Hey,
    Did you tried to put a negative force(the same value for the right, but negative)?
    About the animation, you can flip the animation in the same way, but here you rotate the object in Y-axis. ;)
     
    2dgamemania likes this.
  3. 2dgamemania

    2dgamemania

    Joined:
    Apr 30, 2014
    Posts:
    153
    maybe i shouldnt have posted whilst i had an headache but thank you, pointed me in the right direction (excuse the pun) and got it working now.

    Used

    Code (csharp):
    1.  
    2. transform.eulerAngles = Vector3(0.0, 180, 0.0);
    3.  
    Will work on it at a later date so the character smoothly turns around but at least i can move the character around now.

    Thanks
     
  4. Josenifftodd

    Josenifftodd

    Joined:
    Nov 29, 2013
    Posts:
    158
    I used the animator and set a float so when going left and right with the keys right would be - numbers and forward would be + numbers 0 would be still. This does work if you know how to do it properly, I didn't figure out the backwards motion I just added an animation that when Vertical is being pulled down or pressed on keyboard it walks backwards slowly but the float in the animator would go say -3 and then when let go and up is pressed it would go to say 3 in the float in animator and he does the forward movement, all movement is better set up in the animator I personally think. :)