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. Dismiss Notice

Need help with animation coding...

Discussion in 'Scripting' started by Callumw55, Mar 14, 2014.

  1. Callumw55

    Callumw55

    Joined:
    Mar 11, 2014
    Posts:
    9
    Hello, I was wondering if you could tell me where to insert the animation code for when the player presses "space". I think the correct animation code is: animator.SetParameter("Jump",true);

    This is my code:
    Code (csharp):
    1. function Start () {
    2.  
    3. }
    4.  
    5.   function Update () {
    6.       if (Input.GetKeyDown ("space")){
    7.  
    8.                 transform.Translate(Vector3.up * 30 * Time.deltaTime, Space.World);
    9.                      }
    10.  
    11. }

    Please tell me where to post the code for the animation.

    Many thanks! :D
     
  2. Michael_93

    Michael_93

    Joined:
    Jan 12, 2014
    Posts:
    95
    I'd assume that you put in in the if statement
     
  3. Callumw55

    Callumw55

    Joined:
    Mar 11, 2014
    Posts:
    9
    Thanks, but that didn't work. :/
     
  4. jbecana

    jbecana

    Joined:
    Feb 14, 2012
    Posts:
    22
    I'd follow any tutorial about animator like this. You shouldn't perrform the animation in the script, this should be managed by the animator itself based on your animation clips. If you plan to anímate like this, I think you wouldn't need an animator controller.