Unity C# ''CS1002: ; Expected'' hatası

  • Konuyu başlatan CaGi
  • Başlangıç Tarihi
  • Mesaj 7
  • Görüntüleme 4B

CaGi

Hectopat
Katılım
13 Eylül 2020
Mesajlar
146
Arkadaşlar oyun yapıyordum ve bu hata çıktı ne yapmam gerek.
1616794431345.png

Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class KarakterKontrolu : MonoBehaviour
{
       Rigidbody2D playerRb;
     public float movespeed= 1f;

     bool facingRight = true;


    // Start is called before the first frame update

    void Start()
    {
         playerRb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        playerRb.velocity = new Vector2(Input.GetAxis("Horizontal") * movespeed ,playerRb.velocity.y);
       
         if (playerRb.velocity.x < 0 && facingRight)
         {

             // yuzunu cevır
         }
         else if (playerRb.velocity.x < 0 && !facingRight)
         {

             // yuzunu cevır
         }
     

       
    }
    void HorizontalMove()
    {
        //playerRb.velocity =  new Vector2(Input.GetAxis("Horizontal"),),

    }
    void FlipFace()
    {
        facingRight = !facingRight;
        Vector3 tempLocalScale = transform.localScale;
        tempLocalScale.x *= -1
        transform.localScale = tempLocalScale;
    }
}
 
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class KarakterKontrolu : MonoBehaviour
{
    Rigidbody2D playerRb;
    public float movespeed = 1f;
    bool facingRight = true;

    // Start is called before the first frame update

    void Start()
    {
        playerRb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        playerRb.velocity = new Vector2(Input.GetAxis("Horizontal") * movespeed, playerRb.velocity.y);

        if (playerRb.velocity.x < 0 && facingRight)
        {
            //transform.eulerAngles = new Vector2(0, 0);
        }
        else if (playerRb.velocity.x < 0 && !facingRight)
        {
            //transform.eulerAngles = new Vector2(0, 180);
        }
    }
    void HorizontalMove()
    {
        //playerRb.velocity =  new Vector2(Input.GetAxis("Horizontal"),),
    }
    void FlipFace()
    {
        facingRight = !facingRight;
        Vector3 tempLocalScale = transform.localScale;
        tempLocalScale.x *= -1;
        transform.localScale = tempLocalScale;
    }
}
 
Eki Görüntüle 942885

Ingilizce öğrenmeniz gerekiyor.

Hata kısmında zaten 48. satır 31. sütunda semicolon eksik yazıyor.
peki ne yapmam gerek
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class KarakterKontrolu : MonoBehaviour
{
    Rigidbody2D playerRb;
    public float movespeed = 1f;
    bool facingRight = true;

    // Start is called before the first frame update

    void Start()
    {
        playerRb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        playerRb.velocity = new Vector2(Input.GetAxis("Horizontal") * movespeed, playerRb.velocity.y);

        if (playerRb.velocity.x < 0 && facingRight)
        {
            //transform.eulerAngles = new Vector2(0, 0);
        }
        else if (playerRb.velocity.x < 0 && !facingRight)
        {
            //transform.eulerAngles = new Vector2(0, 180);
        }
    }
    void HorizontalMove()
    {
        //playerRb.velocity =  new Vector2(Input.GetAxis("Horizontal"),),
    }
    void FlipFace()
    {
        facingRight = !facingRight;
        Vector3 tempLocalScale = transform.localScale;
        tempLocalScale.x *= -1;
        transform.localScale = tempLocalScale;
    }
}
bunu kopyalasam olurmu
 
1616837195616.png


1616837215699.png


Hatayı çözebilecek var mı?
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class KarakterKontrolu : MonoBehaviour
{
       Rigidbody2D playerRb;
     public float movespeed= 1f;

     bool facingRight = true;


    // Start is called before the first frame update

    void Start()
    {
         playerRb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        playerRb.velocity = new Vector2(Input.GetAxis("Horizontal") * movespeed ,playerRb.velocity.y);
       
         if (playerRb.velocity.x < 0 && facingRight)
         {

             // yuzunu cevır
         }
         else if (playerRb.velocity.x < 0 && !facingRight)
         {

             // yuzunu cevır
         }
     

       
    }
    void HorizontalMove()
    {
        //playerRb.velocity =  new Vector2(Input.GetAxis("Horizontal"),),

    }
    void FlipFace()
    {
        facingRight = !facingRight;
        Vector3 tempLocalScale = transform.localScale;
        tempLocalScale.x *= -1
        transform.localScale = tempLocalScale;
    }
}
 
Son düzenleyen: Moderatör:
Arkadaşlar Unity'ye gelip varolan kodlama IDE'nizi değiştirirseniz bu tarz hataların hem Türkçesini görebilirsiniz hem de otomatik düzeltmeler ile hata yapma şansınız daha az olur. Altta hataların üzerine tıklayınca Unity de hangi satırda olduğuna kadar açar zaten size. O satıra baktığınız zaman hatayı görebiliyor olmanız gerekiyor.
IDE'yi ayarlamak için sol üstte:
Edit -> Preferences -> External Tools -> External Script Editor den kullandığınız IDE'yi seçin.
Eğer zaten seçiliyse hata durumunda altta sorun bulundu yazar. Ya da kırmızı altı çizili yere mouse'u sürüklerseniz orada hata yazar. Hatayı anlamaya çalışıp çözün.
 
Arkadaşlar oyun yapıyordum ve bu hata çıktı ne yapmam gerek.
Eki Görüntüle 942867
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class KarakterKontrolu : MonoBehaviour
{
       Rigidbody2D playerRb;
     public float movespeed= 1f;

     bool facingRight = true;


    // Start is called before the first frame update

    void Start()
    {
         playerRb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        playerRb.velocity = new Vector2(Input.GetAxis("Horizontal") * movespeed ,playerRb.velocity.y);
      
         if (playerRb.velocity.x < 0 && facingRight)
         {

             // yuzunu cevır
         }
         else if (playerRb.velocity.x < 0 && !facingRight)
         {

             // yuzunu cevır
         }
    

      
    }
    void HorizontalMove()
    {
        //playerRb.velocity =  new Vector2(Input.GetAxis("Horizontal"),),

    }
    void FlipFace()
    {
        facingRight = !facingRight;
        Vector3 tempLocalScale = transform.localScale;
        tempLocalScale.x *= -1
        transform.localScale = tempLocalScale;
    }
}
Hocam herkes söylemiş ama ben de farklıca anlatayım. Kısaca 48.satıra ; işareti koymalısınız. Ayrıca bunun dışında gelen hataların çözümüne en kolay yoldan ulaşmak için: C# derleyicisi iletileri. Sol taraftaki arama yerine hatanızın kodunu yazarsanız açıklamasına ulaşırsınız.
 

Geri
Yukarı