Search Unity

A Noob Question (Programing controls 2d)

Discussion in '2D' started by DanielUDI, Dec 2, 2013.

  1. DanielUDI

    DanielUDI

    Joined:
    Nov 27, 2013
    Posts:
    4
    my character don't jump, don't change the animation on change state, because i'm noob in C# and Java, anda everything...


    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Move : MonoBehaviour
    5. {
    6.     public float speed = 1.0f;
    7.     public string axisName = "Horizontal";
    8.     public Animator anim;
    9.  
    10.     // Use this for initialization
    11.     void Start ()
    12.     {
    13.         anim = gameObject.GetComponent<Animator> ();
    14.     }
    15.    
    16.     // Update is called once per frame
    17.     void Update ()
    18.     {
    19.         anim.SetFloat ("Speed", Mathf.Abs (Input.GetAxis (axisName)));
    20.         if(Input.GetAxis(axisName) < 0)
    21.         {
    22.  
    23.         }
    24.         else if(Input.GetAxis(axisName) > 0)
    25.         {
    26.         }
    27.  
    28.  
    29.         transform.position += transform.right * Input.GetAxis (axisName) * speed * Time.deltaTime;
    30.     }
    31. }
    32.  
    what i need made to works the jump and change the state on walk and on stoped?
    maybe i need to make separated code to jump? explain me...

    i'm not good in english, because i'm from Brazil, sorry
    and i don't understand i wrote, explain as if i were a real noob never view C #, hehe
     
  2. Tiggster

    Tiggster

    Joined:
    May 22, 2013
    Posts:
    29
    You're going to have great difficulty doing anything meaningful until you learn either C# or UnityScript. I'd start there and then come back and give Unity scripting a try.
     
  3. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    Hi Daniel,

    I'll have some beginner video tutorials ready soon that will explain how I accomplish all this and more. Subscribe and check out our Facebook page to stay informed. Cheers!