Search Unity

I don't figure out how to handle it please help me

Discussion in '2D' started by marmarisco860, Mar 28, 2020.

  1. marmarisco860

    marmarisco860

    Joined:
    Mar 28, 2020
    Posts:
    4
    I've been learning unity3d and c# for only 3 days. I watch videos about 2d parkour game in unity with c#. I almost coppied the codes from a guy at the video but the codes or something don't work at this project. please help me. Where am I make the mistake ?
     

    Attached Files:

  2. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    Click on the console at the bottom while running the game and see what errors it throws. You can double click on them to go to the offending line of code. Then you can try and figure out what the issue is. Without knowing what the issue is we cant help you either :)
     
  3. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi @marmarisco860

    "I don't figure out how to handle it please help me"

    Handle it - what it?

    "codes or something don't work at this project. please help me. Where am I make the mistake ?"

    Based on very limited information you gave, hard to say...

    Did you forgot to add a link to the tutorial in question?

    Also, it is better to paste code here with code tags... I personally wouldn't bother to read code from screen capture. You can edit your post with edit button.
     
  4. marmarisco860

    marmarisco860

    Joined:
    Mar 28, 2020
    Posts:
    4
    I left here the code

    Code (CSharp):
    1. public class hareket : MonoBehaviour
    2. {
    3.     Animator animator;
    4.     Rigidbody2D rb2d;
    5.     SpriteRenderer spriteRenderer;
    6.     BoxCollider2D boxCollider2d;
    7.  
    8.     bool isgrounded;
    9.  
    10.     [SerializeField]
    11.     Transform groundCheck;
    12.  
    13.    
    14. void Start()
    15.     {
    16.         animator = GetComponent<Animator>();
    17.         rb2d = GetComponent<Rigidbody2D>();
    18.         spriteRenderer = GetComponent<SpriteRenderer>();
    19.      
    20.     }
    21.  
    22. private void FixedUpdate()
    23.  
    24.     {
    25.         if(Physics2D.Linecast(transform.position, groundCheck.position, 1<< LayerMask.NameToLayer("ground")) || Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("ground2")))
    26.         {
    27.             isgrounded = true;
    28.         }
    29.         else
    30.         {
    31.             isgrounded = false;
    32.  
    33.         }
    34.        
    35.         if (Input.GetKey("d") || Input.GetKey("right"))
    36.         {
    37.             rb2d.velocity = new Vector2(1.8f, rb2d.velocity.y);
    38.  
    39.             if (isgrounded)
    40.                 animator.Play("man_run");
    41.  
    42.             spriteRenderer.flipX = false;
    43.         }
    44.         else if (Input.GetKey("a") || Input.GetKey("left"))
    45.         {
    46.             rb2d.velocity = new Vector2(-1.8f, rb2d.velocity.y);
    47.  
    48.             if (isgrounded)
    49.                 animator.Play("man_run");
    50.  
    51.             spriteRenderer.flipX = true;
    52.  
    53.         }
    54.  
    55.  
    56.         else
    57.         {
    58.             animator.Play("man_idle");
    59.         }
    60.         if ( Input.GetKey("w") && isgrounded)
    61.         {
    62.  
    63.             rb2d.velocity = new Vector2(rb2d.velocity.x, 3);
    64.  
    65.             if (isgrounded)
    66.                 animator.Play("man_jump");
    67.          
    68.         }
    69.  
    70.        
    71.    
    72.     }
    73. }
     
  5. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @marmarisco860

    "I left here the code"

    But you still don't have a question?

    Care to say what doesn't work?

    What error do you get?

    Don't expect that many people start going through your code without first hearing what is wrong with it...