Hocam halletim şimdi de 'if bloklarının sonunda neden noktalı virgül var? Ayrıcarb :
değilrb =
ol
Hocam ilah değilim kodun tamamını yazı şeklinde atarsanız yardımcı olayım. Hatada satır vs. veriyorsa onuda atın.Hocam halletim şimdi de '
Type or namespace definition, or end-of-file expected
' hatası veriyor unity de
using System.Collections;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 (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 şimdideC#: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); } }
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 contextC#: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); } }
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);
}
}
Bu sitenin çalışmasını sağlamak için gerekli çerezleri ve deneyiminizi iyileştirmek için isteğe bağlı çerezleri kullanıyoruz.