Çözüldü Unity hata veriyor

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

fakewarder

Centipat
Katılım
2 Temmuz 2022
Mesajlar
153
Çözümler
1
Daha fazla  
Cinsiyet
Erkek
Using System. Collections;
Using System. Collections. Generic;
Using unityengine;
Public class movement: Monobehaviour
{
Rigidbody2D RB;
Private float horizontal;
Public float Speed;
Bool jump;
Public float jumpforce;
Bool turnright = true;
Vector3 scale;
Void Start()
{
RB = gameObject.GetComponent<Rigidbody2D>();
}
Void FixedUpdate()
{
Horizontal = ınput. Getaxisraw("horizontal");
RB. Velocity = New Vector2(horizontal * Speed [I]250[/I] time. Deltatime, RB. Velocity. Y);
İf (ınput. Getkeydown(keycode. Space)&&jump ==true)
{
RB. Addforce(New Vector2(0, jumpforce));
Jump = false;
}
İf (horizontal <0 turnright == true)
(
Çevir();
)
İf (horizontal> 0 && turnright == false)
(
Çevir();
)
}
Private Void oncollisionenter2D(collision2D collision)
{
İf (collision. Gameobject. Tag =="platform")
{
Jump = true;
}
}

Void Çevir()
(
Turnright =!turnright;
Scale = gameobject. Transform. Localscale;
Scale. X = scale. X* -1;
Gameobject. Transform. Localscale= scale;
)
}

Kodlar bunlar ama ben ne yaptıysam düzeltemedim.
 
Çözüm
Using System. Collections;
Using System. Collections. Generic;
Using unityengine;
Public class movement: Monobehaviour
{
Rigidbody2D RB;
Private float horizontal;
Public float Speed;
Bool jump;
Public float jumpforce;
Bool turnright = true;
Vector3 scale;
Void Start()
{
RB = gameObject.GetComponent<Rigidbody2D>();
}
Void FixedUpdate()
{
Horizontal = ınput. Getaxisraw("horizontal");
RB. Velocity = New Vector2(horizontal * Speed [I]250[/I] time. Deltatime, RB. Velocity. Y);
İf (ınput. Getkeydown(keycode. Space)&&jump ==true)
{
RB. Addforce(New Vector2(0, jumpforce));
Jump = false;
}
İf (horizontal <0 turnright == true)
(
Çevir();
)
İf (horizontal> 0 && turnright == false)
(
Çevir();
)
}
Private Void oncollisionenter2D(collision2D collision)
{
İf (collision. Gameobject. Tag =="platform")
{
Jump = true;
}
}

Void Çevir()
(
Turnright =!turnright;
Scale = gameobject. Transform. Localscale;
Scale. X = scale. X* -1;
Gameobject. Transform. Localscale= scale;
)
}

Kodlar bunlar ama ben ne yaptıysam düzeltemedim.
Kod baştan aşağıya yanlış desek yeridir herhalde. Yeni olduğunuzu düşünüyorum. Kodun düzeltilmiş hali:

C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class movement : MonoBehaviour
{
    Rigidbody2D rb;
    float horizontal;
    public float speed;
    bool jump;
    public float jumpforce;
    bool turnright = true;
    Vector3 scale;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }
   
    void FixedUpdate()
    {
        horizontal = Input.GetAxisRaw("Horizontal");
        rb.velocity = new Vector2(horizontal * speed * Time.deltaTime, rb.velocity.y);
        if(Input.GetKeyDown(KeyCode.Space) && jump == true)
        {
            rb.AddForce(new Vector2(0, jumpforce));
            jump = false;
        }
        if(horizontal < 0 && turnright == true)
        {
            Cevir();
        }
    }
   
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if(collision.gameObject.tag == "platform")
        {
            jump = true;
        }
    }
   
    void Cevir()
    {
        turnright = !turnright;
        scale = gameObject.transform.localScale;
        scale.x = scale.x * -1;
        gameObject.transform.localScale = scale;
    }
}
Using System. Collections;
Using System. Collections. Generic;
Using unityengine;
Public class movement: Monobehaviour
{
Rigidbody2D RB;
Private float horizontal;
Public float Speed;
Bool jump;
Public float jumpforce;
Bool turnright = true;
Vector3 scale;
Void Start()
{
RB = gameObject.GetComponent<Rigidbody2D>();
}
Void FixedUpdate()
{
Horizontal = ınput. Getaxisraw("horizontal");
RB. Velocity = New Vector2(horizontal * Speed [I]250[/I] time. Deltatime, RB. Velocity. Y);
İf (ınput. Getkeydown(keycode. Space)&&jump ==true)
{
RB. Addforce(New Vector2(0, jumpforce));
Jump = false;
}
İf (horizontal <0 turnright == true)
(
Çevir();
)
İf (horizontal> 0 && turnright == false)
(
Çevir();
)
}
Private Void oncollisionenter2D(collision2D collision)
{
İf (collision. Gameobject. Tag =="platform")
{
Jump = true;
}
}

Void Çevir()
(
Turnright =!turnright;
Scale = gameobject. Transform. Localscale;
Scale. X = scale. X* -1;
Gameobject. Transform. Localscale= scale;
)
}

Kodlar bunlar ama ben ne yaptıysam düzeltemedim.
Kod baştan aşağıya yanlış desek yeridir herhalde. Yeni olduğunuzu düşünüyorum. Kodun düzeltilmiş hali:

C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class movement : MonoBehaviour
{
    Rigidbody2D rb;
    float horizontal;
    public float speed;
    bool jump;
    public float jumpforce;
    bool turnright = true;
    Vector3 scale;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }
   
    void FixedUpdate()
    {
        horizontal = Input.GetAxisRaw("Horizontal");
        rb.velocity = new Vector2(horizontal * speed * Time.deltaTime, rb.velocity.y);
        if(Input.GetKeyDown(KeyCode.Space) && jump == true)
        {
            rb.AddForce(new Vector2(0, jumpforce));
            jump = false;
        }
        if(horizontal < 0 && turnright == true)
        {
            Cevir();
        }
    }
   
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if(collision.gameObject.tag == "platform")
        {
            jump = true;
        }
    }
   
    void Cevir()
    {
        turnright = !turnright;
        scale = gameObject.transform.localScale;
        scale.x = scale.x * -1;
        gameObject.transform.localScale = scale;
    }
}
 
Son düzenleme:
Çözüm
Kod baştan aşağıya yanlış desek yeridir herhalde. Yeni olduğunuzu düşünüyorum. Kodun düzeltilmiş hali:

C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class movement : MonoBehaviour
{
    Rigidbody2D rb;
    float horizontal;
    public float speed;
    bool jump;
    public float jumpforce;
    bool turnright = true;
    Vector3 scale;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }
  
    void FixedUpdate()
    {
        horizontal = Input.GetAxisRaw("Horizontal");
        rb.velocity = new Vector2(horizontal * speed * Time.deltaTime, rb.velocity.y);
        if(Input.GetKeyDown(KeyCode.Space) && jump == true)
        {
            rb.AddForce(new Vector2(0, jumpforce));
            jump = false;
        }
        if(horizontal < 0 && turnright == true)
        {
            Cevir();
        }
    }
  
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if(collision.gameObject.tag == "platform")
        {
            jump = true;
        }
    }
  
    void Cevir()
    {
        turnright = !turnright;
        scale = gameObject.transform.localScale;
        scale.x = scale.x * -1;
        gameObject.transform.localScale = scale;
    }
}
evet internetten gördüğüm videolar ile yapmaya çalıştım yeni bu konularda yardımınız için çok sağolun
 
evet internetten gördüğüm videolar ile yapmaya çalıştım yeni bu konularda yardımınız için çok sağolun
Rica ederim, kodları yazarken anlamaya çalışın. Yazdığım ve ya yazılan kodları copy paste yapmayın hocam aman. Bir de Türkçe karakter kullanımına ve büyük harf, küçük harf hatalarına da dikkat edin. Kolay gelsin.
 

Geri
Yukarı