-Type or namespace definition or expected end of file- hatası veriyor şimdideDüzelt düzelt bitmiyor ki.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); } }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Vikingy : MonoBehaviour {
private Rigidbody2D rb;
public 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);
}
}
C#:using System.Collections; using System.Collections.Generic; using UnityEngine; public class Vikingy : MonoBehaviour { private Rigidbody2D rb; public 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); } }
C#:using System.Collections; using System.Collections.Generic; using UnityEngine; public class Vikingy : MonoBehaviour { private Rigidbody2D rb; public 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); } }
C#:using System.Collections; using System.Collections.Generic; using UnityEngine; public class Vikingy : MonoBehaviour { private Rigidbody2D rb; public 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); } }
speed yerine jump yazıp zıplamasını bekliyorsanız bence ilk önce biraz araştırma yapıp neyin ne olduğunu ve C# dilini öğrenin.Şükür oldu hocam eyvallah.
Hocam son bir soru. W tuşunu nasıl zıplama olarak ayarlayabilirim? Speed yerine jump yazdım olmadı.
Şükür oldu hocam eyvallah.
Hocam son bir soru. W tuşunu nasıl zıplama olarak ayarlayabilirim? Speed yerine jump yazdım olmadı.
if (Input.GetKey(KeyCode.W))
rb.AddForce(Vector3.up*3);
eyvallah hocamKonuya hort diye daliyorum kusura bakmayin sanirim eğitim videosu izliyorsunuz Unity'de oyun yapiyor iseniz ve sifirdan direk eğitim videosuyla daliyor iseniz bu ileride büyük problemlere yol açar. Her işte olduğu gibi bunun öncesini de öğrenmelisiniz, nasıl çarpim tablosunu bilmeden matematim yapamiyorsak Unity'de az buçuk C# bilgisiz oyun yapamayiz. Berkaprod gibi birkaç Türkçe içerik üreticilerine bakmanizi öneririm temel ve anlaşilir anlatiyorlar C#'dilini.
Soruna gelirsek.
Her şeye Speed atamişsiniz. Atadiğiniz tuşlarla şu an sadece yürüyebilirsiniz W ile ziplamak için şunu kulanabiliriz.
C#:if (Input.GetKey(KeyCode.W)) rb.AddForce(Vector3.up*3);
Addforce ye Vector3 cinsinden bir kuvvet kulandik ve bunu 3 ile çarptik/katla
Bu sitenin çalışmasını sağlamak için gerekli çerezleri ve deneyiminizi iyileştirmek için isteğe bağlı çerezleri kullanıyoruz.