Çözüldü Unity CS1525 hatası

Bu konu çözüldü olarak işaretlenmiştir. Çözülmediğini düşünüyorsanız konuyu rapor edebilirsiniz.

Cag04n

Femtopat
Katılım
27 Kasım 2022
Mesajlar
67
Daha fazla  
Cinsiyet
Erkek
Aslında çok basit bir hata ama bir türlü çözemedim.

1670149946519.png


1670149933287.png
 
Çözüm
new Vector3(h, 0, ) kısmında virgülden sonra da bir şey girilmesi gerekiyor. 0 girebilirsiniz hatanın gitmesi için. Şöyle çalışır yani new Vector3(h, 0, 0) ama istediğiniz mi olur bilmiyorum oraya ne gelecek yapmak istediğinize siz karar vermelisiniz :D.
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
    public Transform aimTarget;
    float speed = 3f;

    bool hitting;
    void Update()
    {
        float h = Input.GetAxisRaw("Horizontal");
        float v = Input.GetAxisRaw("Vertical");

        if (Input.GetKeyDown(KeyCode.F)) ;
        {
            hitting = true;
        }
        if (Input.GetKeyUp(KeyCode.F)) ;
        {
            hitting = false;
        }

        if (hitting)
        {
            aimTarget.Translate(new Vector3(h, 0, 0) * speed * Time.deltaTime);
            {


                if (h != 0 || v != 0)
                {
                    transform.Translate(new Vector3(h, 0, v) * speed * Time.deltaTime);
                }
            }
        }
    }
}
Düzeltilmiş hali. İki süslü parantez atlamışsın.
 
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour.
{
 public Transform aimTarget;
 float speed = 3f;

 bool hitting;
 void Update()
 {
 float h = Input.GetAxisRaw("Horizontal");
 float v = Input.GetAxisRaw("Vertical");

 if (Input.GetKeyDown(KeyCode.F)) ;
 {
 hitting = true;
 }
 if (Input.GetKeyUp(KeyCode.F)) ;
 {
 hitting = false;
 }

 if (hitting)
 {
 aimTarget.Translate(new Vector3(h, 0, 0) * speed * Time.deltaTime);
 {

 if (h != 0 || v != 0)
 {
 transform.Translate(new Vector3(h, 0, v) * speed * Time.deltaTime);
 }
 }
 }
 }
}
Düzeltilmiş hali. İki süslü parantez atlamışsın.
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour.
{
 public Transform aimTarget;
 float speed = 3f;

 bool hitting;
 void Update()
 {
 float h = Input.GetAxisRaw("Horizontal");
 float v = Input.GetAxisRaw("Vertical");

 if (Input.GetKeyDown(KeyCode.F)) ;
 {
 hitting = true;
 }
 if (Input.GetKeyUp(KeyCode.F)) ;
 {
 hitting = false;
 }

 if (hitting)
 {
 aimTarget.Translate(new Vector3(h, 0, 0) * speed * Time.deltaTime);
 {

 if (h != 0 || v != 0)
 {
 transform.Translate(new Vector3(h, 0, v) * speed * Time.deltaTime);
 }
 }
 }
 }
}
Düzeltilmiş hali. İki süslü parantez atlamışsın.
Tamam şimdi anladım sağ ol.

Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour.
{
 public Transform aimTarget;
 float speed = 3f;

 bool hitting;
 void Update()
 {
 float h = Input.GetAxisRaw("Horizontal");
 float v = Input.GetAxisRaw("Vertical");

 if (Input.GetKeyDown(KeyCode.F)) ;
 {
 hitting = true;
 }
 if (Input.GetKeyUp(KeyCode.F)) ;
 {
 hitting = false;
 }

 if (hitting)
 {
 aimTarget.Translate(new Vector3(h, 0, 0) * speed * Time.deltaTime);
 {

 if (h != 0 || v != 0)
 {
 transform.Translate(new Vector3(h, 0, v) * speed * Time.deltaTime);
 }
 }
 }
 }
}
Düzeltilmiş hali. İki süslü parantez atlamışsın.

Sanırsam elseyi sildigim icin bilmiyorum şu anda karakterimi hareket etiremiyorum sizce ne yapmalıyım elseyi ekledigim zaman.

1670155755361.png


1670155771472.png


Bu hatalar cıkıyor.
 
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{

    public Transform aimTarget;
    float speed = 3f;
    
    bool hitting;

    void Update()
    {
        float h = Input.GetAxisRaw("Horizontal");
        float v = Input.GetAxisRaw("Vertical");
        
        if(Input.GetKeyDown(KeyCode.F));
        {
             hitting = true;
        }else if(Input.GetKeyUp(KeyCode.F));
        {
              hitting = false;
        }   
          
        if ( hitting)
        {
            aimTarget.Translate (new Vector3(h ,0 , 0 ) * speed * Time.deltaTime);
        { 
            
        
              if ( h != 0 || v != 0)
              {
                 transform.Translate(new Vector3(h , 0 , v ) * speed * Time.deltaTime );
              }

           }
        }
    }
}

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

public class Player : MonoBehaviour.
{

 public Transform aimTarget;
 float speed = 3f;

 bool hitting;

 void Update()
 {
 float h = Input.GetAxisRaw("Horizontal");
 float v = Input.GetAxisRaw("Vertical");

 if(Input.GetKeyDown(KeyCode.F));
 {
 hitting = true;
 }else if(Input.GetKeyUp(KeyCode.F));
 {
 hitting = false;
 }

 if ( hitting)
 {
 aimTarget.Translate (new Vector3(h ,0 , 0 ) * speed * Time.deltaTime);
 {

 if ( h != 0 || v != 0)
 {
 transform.Translate(new Vector3(h , 0 , v ) * speed * Time.deltaTime );
 }

 }
 }
 }
}

Adamın koduyla aynı.
 
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{

    public Transform aimTarget;
    float speed = 3f;

    bool hitting;

    void Update()
    {
        float h = Input.GetAxisRaw("Horizontal");
        float v = Input.GetAxisRaw("Vertical");

        if (Input.GetKeyDown(KeyCode.F))
        {
            hitting = true;
        }
        else if (Input.GetKeyUp(KeyCode.F))
        {
            hitting = false;
        }

        if (hitting)
        {
            aimTarget.Translate(new Vector3(h, 0, 0) * speed * Time.deltaTime);
            {


                if (h != 0 || v != 0)
                {
                    transform.Translate(new Vector3(h, 0, v) * speed * Time.deltaTime);
                }

            }
        }
    }
}
If ve Else ifadesinin sonuna tanımlarken noktalı virgül konulmaz.
 
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour.
{

 public Transform aimTarget;
 float speed = 3f;

 bool hitting;

 void Update()
 {
 float h = Input.GetAxisRaw("Horizontal");
 float v = Input.GetAxisRaw("Vertical");

 if (Input.GetKeyDown(KeyCode.F))
 {
 hitting = true;
 }
 else if (Input.GetKeyUp(KeyCode.F))
 {
 hitting = false;
 }

 if (hitting)
 {
 aimTarget.Translate(new Vector3(h, 0, 0) * speed * Time.deltaTime);
 {

 if (h != 0 || v != 0)
 {
 transform.Translate(new Vector3(h, 0, v) * speed * Time.deltaTime);
 }

 }
 }
 }
}
If ve else ifadesinin sonuna tanımlarken noktalı virgül konulmaz.

Evet ama noktali virgülü silsemde hataların hiçbiri gitmiyor.

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

public class Player : MonoBehaviour.
{

 public Transform aimTarget;
 float speed = 3f;

 bool hitting;

 void Update()
 {
 float h = Input.GetAxisRaw("Horizontal");
 float v = Input.GetAxisRaw("Vertical");

 if (Input.GetKeyDown(KeyCode.F))
 {
 hitting = true;
 }
 else if (Input.GetKeyUp(KeyCode.F))
 {
 hitting = false;
 }

 if (hitting)
 {
 aimTarget.Translate(new Vector3(h, 0, 0) * speed * Time.deltaTime);
 {

 if (h != 0 || v != 0)
 {
 transform.Translate(new Vector3(h, 0, v) * speed * Time.deltaTime);
 }

 }
 }
 }
}
If ve else ifadesinin sonuna tanımlarken noktalı virgül konulmaz.

Hatalar gitti düzeldi fakat karakteri hala hareket etiremiyorum sizce nedeni ne olabilir?

Evet ama noktali virgülü silsemde hataların hiçbiri gitmiyor.

Hatalar gitti düzeldi fakat karakteri hala hareket etiremiyorum sizce nedeni ne olabilir?
 
Son düzenleme:
İzlediğiniz Video'yu atmadan bilemem birçok yerde hata yapmış olma olasılığınız var. Ne tarz oyun yaptığınızıda bilmiyorum. Videonun bazı kısımlarını atlamışsınızdır belki ya da yanlış yapmışsınızdır.
En basit olarak bunu deneyebilirsiniz.
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
    public float hareketHizi=1f;
    void Update()
    {
        float h = Input.GetAxisRaw("Horizontal");
        float v = Input.GetAxisRaw("Vertical");
        gameObject.transform.position = new Vector2(transform.position.x + (h * hareketHizi),transform.position.y + (v * hareketHizi));
    }
}
 
Son düzenleme:
İzlediğiniz Video'yu atmadan bilemem birçok yerde hata yapmış olma olasılığınız var. Ne tarz oyun yaptığınızıda bilmiyorum. Videonun bazı kısımlarını atlamışsınızdır belki ya da yanlış yapmışsınızdır.
En basit olarak bunu deneyebilirsiniz.
Kod:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour.
{
 public float speed=1f;
 void Update()
 {
 float h = Input.GetAxisRaw("Horizontal");
 float v = Input.GetAxisRaw("Vertical");
 gameObject.transform.position = new Vector2(transform.position.x + (h * speed),transform.position.y + (v * speed));
 }
}

Şimdi şu şekilde.

Bu içeriği görüntülemek için üçüncü taraf çerezlerini yerleştirmek için izninize ihtiyacımız olacak.
Daha detaylı bilgi için, çerezler sayfamıza bakınız.

Bu izledigim video ve yazdıgım kodlarda şu anda sadece aim targeti hareket etirebiliyorum F ye bastıgım zaman fakat karakterimi hareket etiremiyorum.

1670157570894.png


1670157560787.png
 

Geri
Yukarı