Unity CS1002 expected hatası

fratalkanan

Femtopat
Katılım
9 Eylül 2023
Mesajlar
7
Daha fazla  
Cinsiyet
Erkek
Arkadaşlar o kadar kod yazdım ettim. Ancak CS1002 expected diyor kodlar burada yardım.
Kod:
Using System. Collections;

Using System. Collections. Generic;

Using unityengine;



Public class top: Monobehaviour.

{



 Public rigidbody2D rb;

 Public float hiz;

 Public float gol_1, gol_2;

 Public textmeshpro gol1, gol2;



 // Start is called before the first frame Update.

 Void Start()

 {

 Hiz = 180F;

 }



 // Update is called once per frame.

 Void Update()

 {



 }



Public Void oncollisionstay2D(collision2D temas) {



 İf(temas. Gameobject. Tag =="oyuncu2") {

 İf(ınput. Getkey(keycode. K)){

 İf(ınput. Getkey(keycode. Uparrow)){

 Rb. Addforce(Vector2.up * hiz);

 }



 İf(ınput. Getkey(keycode. Downarrow)){

 Rb. Addforce(Vector2.down * hiz);

 }



 İf(ınput. Getkey(keycode. Rightarrow)){

 Rb. Addforce(Vector2.right * hiz);

 }

 İf(ınput. Getkey(keycode. Leftarrow)){

 Rb. Addforce(Vector2.left * hiz);

 }



 }



 }

 İf(temas. Gameobject. Tag =="oyuncu1") {

 İf(ınput. Getkey(keycode. Space)){

 İf(ınput. Getkey(keycode. W)){

 Rb. Addforce(Vector2.up * hiz);

 }



 İf(ınput. Getkey(keycode. S)){

 Rb. Addforce(Vector2.down * hiz);

 }



 İf(ınput. Getkey(keycode. D)){

 Rb. Addforce(Vector2.right * hiz);

 }

 İf(ınput. Getkey(keycode. A)){

 Rb. Addforce(Vector2.left * hiz);

 }



 }



 }



}

 Public Void oncollisionenter2D(collision2D kale_gol){

 İf(kale_gol. Gameobject. Tag=="kale1"){

 Gol_1 += 1;

 Gol2.text = gol_1 ToString();



 }



 }
 
void Start()

{

Hiz = 180f;

}
Burada 180F olarak yazmanız gerekiyor. Ama hatanın tamamını atarsanız ve hangi satır hangi kodda olduğunu da yazarsanız daha iyi yardımcı olabilirim
 
Bu arada kodun tamamı hatalı, full yazım hatası var.
 
Arkadaşlar o kadar kod yazdım ettim. Ancak CS1002 expected diyor kodlar burada yardım.
Kod:
Using System. Collections;

Using System. Collections. Generic;

Using unityengine;



Public class top: Monobehaviour.

{



 Public rigidbody2D rb;

 Public float hiz;

 Public float gol_1, gol_2;

 Public textmeshpro gol1, gol2;



 // Start is called before the first frame Update.

 Void Start()

 {

 Hiz = 180F;

 }



 // Update is called once per frame.

 Void Update()

 {



 }



Public Void oncollisionstay2D(collision2D temas) {



 İf(temas. Gameobject. Tag =="oyuncu2") {

 İf(ınput. Getkey(keycode. K)){

 İf(ınput. Getkey(keycode. Uparrow)){

 Rb. Addforce(Vector2.up * hiz);

 }



 İf(ınput. Getkey(keycode. Downarrow)){

 Rb. Addforce(Vector2.down * hiz);

 }



 İf(ınput. Getkey(keycode. Rightarrow)){

 Rb. Addforce(Vector2.right * hiz);

 }

 İf(ınput. Getkey(keycode. Leftarrow)){

 Rb. Addforce(Vector2.left * hiz);

 }



 }



 }

 İf(temas. Gameobject. Tag =="oyuncu1") {

 İf(ınput. Getkey(keycode. Space)){

 İf(ınput. Getkey(keycode. W)){

 Rb. Addforce(Vector2.up * hiz);

 }



 İf(ınput. Getkey(keycode. S)){

 Rb. Addforce(Vector2.down * hiz);

 }



 İf(ınput. Getkey(keycode. D)){

 Rb. Addforce(Vector2.right * hiz);

 }

 İf(ınput. Getkey(keycode. A)){

 Rb. Addforce(Vector2.left * hiz);

 }



 }



 }



}

 Public Void oncollisionenter2D(collision2D kale_gol){

 İf(kale_gol. Gameobject. Tag=="kale1"){

 Gol_1 += 1;

 Gol2.text = gol_1 ToString();



 }



 }
Hocam kodu düzelt demeden atma şansınız var mı? Böyle anlaşılmıyor.
 
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TOP : MonoBehaviour
{
    
    
    public Rigidbody2D rb;
    public float hiz;
     public float gol_1,gol_2;
     public TextMeshPro gol1,gol2;
    
    
    // Start is called before the first frame update
    void Start()
    {
     hiz = 180f;   
    }

    // Update is called once per frame
    void Update()
    {
  
    }
    
    
    
public void OnCollisionStay2D(Collision2D temas) {
    
    if(temas.gameObject.tag =="Oyuncu2") {
          if(Input.GetKey(KeyCode.K)){
              if(Input.GetKey(KeyCode.UpArrow)){
                rb.AddForce(Vector2.up * hiz);
            }
            
            if(Input.GetKey(KeyCode.DownArrow)){
                rb.AddForce(Vector2.down * hiz);
            }
            
            if(Input.GetKey(KeyCode.RightArrow)){
                rb.AddForce(Vector2.right * hiz);
            }
            if(Input.GetKey(KeyCode.LeftArrow)){
                rb.AddForce(Vector2.left * hiz);
            }
            
            
            
            
            
        }
        
        
        }
    if(temas.gameObject.tag =="Oyuncu1") {
          if(Input.GetKey(KeyCode.Space)){
              if(Input.GetKey(KeyCode.W)){
                rb.AddForce(Vector2.up * hiz);
            }
            
            if(Input.GetKey(KeyCode.S)){
                rb.AddForce(Vector2.down * hiz);
            }
            
            if(Input.GetKey(KeyCode.D)){
                rb.AddForce(Vector2.right * hiz);
            }
            if(Input.GetKey(KeyCode.A)){
                rb.AddForce(Vector2.left * hiz);
            }
            
            
            
          
            
        }
        
        
        }
        
}
    public void OnCollisionEnter2D(Collision2D kale_gol){
        if(kale_gol.gameObject.tag=="Kale1"){
            gol_1 += 1;
            gol2.text = gol_1 ToString();
            
        }
        
        
        
    }
    
    
    
    
    
    
    
    
}

arkadaşlar kodlar burada CS1002 expected ; hatası kodun tamamı nolur yardım
 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class TOP : MonoBehaviour
{


public Rigidbody2D rb;
public float hiz;
public float gol_1,gol_2;
public TextMeshPro gol1,gol2;


// Start is called before the first frame update
void Start()
{
hiz = 180f;
}
// Update is called once per frame
void Update()
{

}



public void OnCollisionStay2D(Collision2D temas) {

if(temas.gameObject.tag =="Oyuncu2") {
if(Input.GetKey(KeyCode.K)){
if(Input.GetKey(KeyCode.UpArrow)){
rb.AddForce(Vector2.up * hiz);
}

if(Input.GetKey(KeyCode.DownArrow)){
rb.AddForce(Vector2.down * hiz);
}

if(Input.GetKey(KeyCode.RightArrow)){
rb.AddForce(Vector2.right * hiz);
}
if(Input.GetKey(KeyCode.LeftArrow)){
rb.AddForce(Vector2.left * hiz);
}





}


}
if(temas.gameObject.tag =="Oyuncu1") {
if(Input.GetKey(KeyCode.Space)){
if(Input.GetKey(KeyCode.W)){
rb.AddForce(Vector2.up * hiz);
}

if(Input.GetKey(KeyCode.S)){
rb.AddForce(Vector2.down * hiz);
}

if(Input.GetKey(KeyCode.D)){
rb.AddForce(Vector2.right * hiz);
}
if(Input.GetKey(KeyCode.A)){
rb.AddForce(Vector2.left * hiz);
}





}


}

}
public void OnCollisionEnter2D(Collision2D kale_gol){
if(kale_gol.gameObject.tag=="Kale1"){
gol_1 += 1;
gol2.text = gol_1.ToString();

}



}








}

Bu kodu kopyala yapıştır

Son satırdaki gol2.text = gol_1.ToString(); kodunda gol_1 ToString(); yamışsın. Araya "." koymalıydın. Bir de TextMeshPro kullanıyorsun madem o zaman kütüphanesini de eklemen gerekiyordu. Onu ekledim. şimdi hata almaman lazım.
 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class TOP : MonoBehaviour
{


public Rigidbody2D rb;
public float hiz;
public float gol_1,gol_2;
public TextMeshPro gol1,gol2;


// Start is called before the first frame update
void Start()
{
hiz = 180f;
}
// Update is called once per frame
void Update()
{

}



public void OnCollisionStay2D(Collision2D temas) {

if(temas.gameObject.tag =="Oyuncu2") {
if(Input.GetKey(KeyCode.K)){
if(Input.GetKey(KeyCode.UpArrow)){
rb.AddForce(Vector2.up * hiz);
}

if(Input.GetKey(KeyCode.DownArrow)){
rb.AddForce(Vector2.down * hiz);
}

if(Input.GetKey(KeyCode.RightArrow)){
rb.AddForce(Vector2.right * hiz);
}
if(Input.GetKey(KeyCode.LeftArrow)){
rb.AddForce(Vector2.left * hiz);
}





}


}
if(temas.gameObject.tag =="Oyuncu1") {
if(Input.GetKey(KeyCode.Space)){
if(Input.GetKey(KeyCode.W)){
rb.AddForce(Vector2.up * hiz);
}

if(Input.GetKey(KeyCode.S)){
rb.AddForce(Vector2.down * hiz);
}

if(Input.GetKey(KeyCode.D)){
rb.AddForce(Vector2.right * hiz);
}
if(Input.GetKey(KeyCode.A)){
rb.AddForce(Vector2.left * hiz);
}





}


}

}
public void OnCollisionEnter2D(Collision2D kale_gol){
if(kale_gol.gameObject.tag=="Kale1"){
gol_1 += 1;
gol2.text = gol_1.ToString();

}



}








}

Bu kodu kopyala yapıştır

Son satırdaki gol2.text = gol_1.ToString(); kodunda gol_1 ToString(); yamışsın. Araya "." koymalıydın. Bir de TextMeshPro kullanıyorsun madem o zaman kütüphanesini de eklemen gerekiyordu. Onu ekledim. şimdi hata almaman lazım.
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TOP : MonoBehaviour
{


public Rigidbody2D rb;
public float hiz;
public float gol_1,gol_2;
public Text gol1,gol2;


// Start is called before the first frame update
void Start()
{
hiz = 180f;

gol_1=0;
gol_2=0;
}
// Update is called once per frame
void Update()
{

}



public void OnCollisionStay2D(Collision2D temas) {

if(temas.gameObject.tag =="Oyuncu2") {
if(Input.GetKey(KeyCode.K)){
if(Input.GetKey(KeyCode.UpArrow)){
rb.AddForce(Vector2.up * hiz);
}

if(Input.GetKey(KeyCode.DownArrow)){
rb.AddForce(Vector2.down * hiz);
}

if(Input.GetKey(KeyCode.RightArrow)){
rb.AddForce(Vector2.right * hiz);
}
if(Input.GetKey(KeyCode.LeftArrow)){
rb.AddForce(Vector2.left * hiz);
}





}


}
if(temas.gameObject.tag =="Oyuncu1") {
if(Input.GetKey(KeyCode.Space)){
if(Input.GetKey(KeyCode.W)){
rb.AddForce(Vector2.up * hiz);
}

if(Input.GetKey(KeyCode.S)){
rb.AddForce(Vector2.down * hiz);
}

if(Input.GetKey(KeyCode.D)){
rb.AddForce(Vector2.right * hiz);
}
if(Input.GetKey(KeyCode.A)){
rb.AddForce(Vector2.left * hiz);
}





}


}

}
public void OnCollisionEnter2D(Collision2D kale_gol){
if(kale_gol.gameObject.tag=="Kale1"){
gol_1 += 1;
gol2.text = gol_1.ToString();

}



}








}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class TOP : MonoBehaviour
{


public Rigidbody2D rb;
public float hiz;
public float gol_1,gol_2;
public TextMeshPro gol1,gol2;


// Start is called before the first frame update
void Start()
{
hiz = 180f;
}
// Update is called once per frame
void Update()
{

}



public void OnCollisionStay2D(Collision2D temas) {

if(temas.gameObject.tag =="Oyuncu2") {
if(Input.GetKey(KeyCode.K)){
if(Input.GetKey(KeyCode.UpArrow)){
rb.AddForce(Vector2.up * hiz);
}

if(Input.GetKey(KeyCode.DownArrow)){
rb.AddForce(Vector2.down * hiz);
}

if(Input.GetKey(KeyCode.RightArrow)){
rb.AddForce(Vector2.right * hiz);
}
if(Input.GetKey(KeyCode.LeftArrow)){
rb.AddForce(Vector2.left * hiz);
}





}


}
if(temas.gameObject.tag =="Oyuncu1") {
if(Input.GetKey(KeyCode.Space)){
if(Input.GetKey(KeyCode.W)){
rb.AddForce(Vector2.up * hiz);
}

if(Input.GetKey(KeyCode.S)){
rb.AddForce(Vector2.down * hiz);
}

if(Input.GetKey(KeyCode.D)){
rb.AddForce(Vector2.right * hiz);
}
if(Input.GetKey(KeyCode.A)){
rb.AddForce(Vector2.left * hiz);
}





}


}

}
public void OnCollisionEnter2D(Collision2D kale_gol){
if(kale_gol.gameObject.tag=="Kale1"){
gol_1 += 1;
gol2.text = gol_1.ToString();

}



}








}

Bu kodu kopyala yapıştır

Son satırdaki gol2.text = gol_1.ToString(); kodunda gol_1 ToString(); yamışsın. Araya "." koymalıydın. Bir de TextMeshPro kullanıyorsun madem o zaman kütüphanesini de eklemen gerekiyordu. Onu ekledim. şimdi hata almaman lazım.
sıddık ben artık textmeshpro kullanmıyorum ona göre yaptım ama şu anda failed to find entry-points diyor bu kodda nolur bi el atsan
 

Yeni konular

Geri
Yukarı