Error CS1513: } expected HATASI

bran3444

Centipat
Katılım
25 Ocak 2022
Mesajlar
8
Daha fazla  
Cinsiyet
Erkek
-Arkadaşlar oyun yapmak için kodlama yapıyorum fakat 'error CS1513: } expected ' HATASI veriyor. Yazdıklarım ise bunlar yardımcı olur musunuz?
 

Dosya Ekleri

  • ABC.jpg
    ABC.jpg
    216,1 KB · Görüntüleme: 39
Hocam ilah değilim kodun tamamını yazı şeklinde atarsanız yardımcı olayım. Hatada satır vs. veriyorsa onuda atın.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Vikingy : MonoBehaviour


private Rigidbody2D rb2;
float speed = 2f;


void Start()
{



rb = GetComponent<Rigidbody2D>();

}

void Update()
{


if (Inpute.GetKey(KeyCode W)) ;
rb2.AddForce(Vector2.up * speed);


if (Inpute.GetKey(KeyCode A)) ;
rb2.AddForce(Vector2.left * speed);


if ((Ipute.GetKey(KeyCode D))) ;, }
rb2.AddForce(Vector2.left * speed);
}
 
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Vikingy : MonoBehaviour {
   
    private Rigidbody2D rb2;
    float speed = 2f;
   
    void Start() {
        rb = GetComponent<Rigidbody2D>();
    }

    void Update() {
       
        if (Input.GetKey(KeyCode.W))
            rb2.AddForce(Vector2.up * speed);
       
        if (Input.GetKey(KeyCode.A))
            rb2.AddForce(Vector2.left * speed);
       
        if (Input.GetKey(KeyCode.D))
            rb2.AddForce(Vector2.right * speed);
    }
}
 
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Vikingy : MonoBehaviour {
  
    private Rigidbody2D rb2;
    float speed = 2f;
  
    void Start() {
        rb = GetComponent<Rigidbody2D>();
    }

    void Update() {
      
        if (Input.GetKey(KeyCode.W))
            rb2.AddForce(Vector2.up * speed);
      
        if (Input.GetKey(KeyCode.A))
            rb2.AddForce(Vector2.left * speed);
      
        if (Input.GetKey(KeyCode.D))
            rb2.AddForce(Vector2.right * speed);
    }
}
hocam yazdığınızı yaptım fakat -The name 'rb' does not exist in the current context- hatası veriyor şimdide
 
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Vikingy : MonoBehaviour {
  
    private Rigidbody2D rb;
    float speed = 2f;
  
    void Start() {
        rb = GetComponent<Rigidbody2D>();
    }

    void Update() {
      
        if (Input.GetKey(KeyCode.W))
            rb2.AddForce(Vector2.up * speed);
      
        if (Input.GetKey(KeyCode.A))
            rb2.AddForce(Vector2.left * speed);
      
        if (Input.GetKey(KeyCode.D))
            rb2.AddForce(Vector2.right * speed);
    }
}
 
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Vikingy : MonoBehaviour {
 
    private Rigidbody2D rb;
    float speed = 2f;
 
    void Start() {
        rb = GetComponent<Rigidbody2D>();
    }

    void Update() {
     
        if (Input.GetKey(KeyCode.W))
            rb2.AddForce(Vector2.up * speed);
     
        if (Input.GetKey(KeyCode.A))
            rb2.AddForce(Vector2.left * speed);
     
        if (Input.GetKey(KeyCode.D))
            rb2.AddForce(Vector2.right * speed);
    }
}
The name 'rb2' does not exist in the current context
bu hatayı veriyor
 
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Vikingy : MonoBehaviour {
 
    private Rigidbody2D rb;
    float speed = 2f;
 
    void Start() {
        rb = GetComponent<Rigidbody2D>();
    }

    void Update() {
     
        if (Input.GetKey(KeyCode.W))
            rb.AddForce(Vector2.up * speed);
     
        if (Input.GetKey(KeyCode.A))
            rb.AddForce(Vector2.left * speed);
     
        if (Input.GetKey(KeyCode.D))
            rb.AddForce(Vector2.right * speed);
    }
}
Düzelt düzelt bitmiyor ki.
 

Yeni konular

Geri
Yukarı