Someting Wrong

Sayac1 =

counting those with a basket

Sayac2 =
Counting out

Question :
I want to use 7 shots.
if (Sayac1) counter 3 and more, the new section ( public string LevelPassed) Howewer if(sayac2) counter 5 and more restart game (public string YenidenOyna)

A FEW NOTE ;
I gave 7 numbers to “top” but
something went wrong
The section was not completed despite having 3 baskets

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class Skor : MonoBehaviour
{
   
    public string Menu;
    public GameObject music;
    [SerializeField] private GameObject Image;
    [SerializeField] private GameObject Image2;
    [SerializeField] private GameObject Image3;
    [SerializeField] private GameObject Image4;
    [SerializeField] private GameObject Image5;
    [SerializeField] private GameObject Image6;
    [SerializeField] private GameObject Image7;
    [SerializeField] private GameObject Red;
    [SerializeField] private GameObject Red2;
    [SerializeField] private GameObject Red3;
    [SerializeField] private GameObject Red4;
    [SerializeField] private GameObject Red5;
    [SerializeField] private GameObject Red6;
    [SerializeField] private GameObject Red7;
    private int sayı; 
    private int sayac;
    private int sayac2;
    private int top;
    public string LevelPassed;
    public string YenidenOyna;
    private void Start()
    {
        sayı = 0;
        sayac = 0;
        sayac2 = 0;
        top = 7;
        Image.SetActive(false);
        Image2.SetActive(false);
        Image3.SetActive(false);
        Image4.SetActive(false);
        Image5.SetActive(false);
        Image6.SetActive(false);
        Image7.SetActive(false);
        Red.SetActive(false);
        Red2.SetActive(false);
        Red3.SetActive(false);
        Red4.SetActive(false);
        Red5.SetActive(false);
        Red6.SetActive(false);
        Red7.SetActive(false);
    }

   
    private void Başarılı()
    {
        if (top == 7 && sayac >= 3)
        {
            Debug.Log("Yeni Level");
            SceneManager.LoadScene(LevelPassed);
           
        }else if(top == 7 && sayac2 >= 5)
        {
                Debug.Log("Level Başarısız");
                SceneManager.LoadScene(YenidenOyna);
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("basket"))
        {
            sayac = sayac + 1;
            Debug.Log("Sayac : " + sayac);
            top = top - 1;
            Debug.Log("Top Kalan : " + top);
            Başarılı();
            sayı = sayı + 1;
           
            if (sayı==1 && Red.activeSelf == false)
            {
                Image.SetActive(true);
            }
            if (sayı==2 && Red2.activeSelf == false)
            {
                Image2.SetActive(true);
            }
            if (sayı==3 && Red3.activeSelf == false)
            {
                Image3.SetActive(true);
            }
            if (sayı == 4 && Red4.activeSelf == false)
            {
                Image4.SetActive(true);
            }
            if (sayı == 5 && Red5.activeSelf == false)
            {
                Image5.SetActive(true);
            }
            if (sayı == 6 && Red6.activeSelf == false)
            {
                Image6.SetActive(true);
            }
            if (sayı == 7 && Red7.activeSelf == false)
            {
                Image7.SetActive(true);
            }
        }
       
        if (other.gameObject.CompareTag("Respawn"))
        {
            sayı = sayı + 1;
            sayac2 = sayac2 + 1;
            Debug.Log("Sayac2 : " + sayac2);
            Başarılı();
            top = top - 1;
            Debug.Log("Top Kalan : " + top);

            if (sayı == 1 && Image.activeSelf == false)
            {
                Red.SetActive(true);
            }
            if (sayı == 2 && Image2.activeSelf == false)
            {
                Red2.SetActive(true);
            }
            if (sayı == 3 && Image3.activeSelf == false)
            {
                Red3.SetActive(true);
            }
            if (sayı == 4 && Image4.activeSelf == false)
            {
                Red4.SetActive(true);
            }
            if (sayı == 5 && Image5.activeSelf == false)
            {
                Red5.SetActive(true);
            }
            if (sayı == 6 && Image6.activeSelf == false)
            {
                Red6.SetActive(true);
            }
            if (sayı == 7 && Image7.activeSelf == false)
            {
                Red7.SetActive(true);
            }

        }

    }
   
   
}

Your win and lose conditions will never be reached based off the code you’ve written.

It’s because you’re changing your top variable every shot but when you check your win or lose conditions you’re checking that top == to whatever you set it to at the start which it will never be (in this case 7), so you will never lose or win.

Why do you even bother checking if top == 7? surely you should be checking if it’s larger than zero before you let the user shoot, otherwise they can shoot as many times as they want.

EDIT: The reason most people are not going to bother replying to this thread is because

  1. You haven’t demonstrated that you have tried to solve it yourself
  2. It’s not entirely in English (this being an English speaking forum)
  3. Your variable names are poorly named. (e.g sayac1, sayac2, top, why not give more meaningful names such as Vurmak, Bayan, Denemeler? or in English, Hit, Miss, Attempts).
  4. Something went wrong is very vague, what circumstances does it go right?

To help in replies another thing you could do is (especially for beginners) comment your code! It will help you as well trying to figure out what is going wrong!

I created 7 balls, but I want the system to know that when “count” is 3, it uses the new part and seven “balls”.

I want to users use to seven balls and if three ball basket new scene howewer 5 and more Collider enter respawn restart scene

brothers ?

When the basket is 3, go to the new scene but the user must wait for 7 balls to finish

I tried explaining this in private message, but I’ll explain it here again.

Like @CubicCBridger was saying, what is wrong is when Başarılı() is called, the value of “top” is not going to be 7 at the same time the value of sayac is >= 3 or the value of sayac2 is >= 5. It is not possible for both to be true because by the time sayac and sayac2 are high enough you will have called “top = top - 1;” on lines 75 and 116 several times.

That means “top” will not be equal to 7, so you should not be checking for “top == 7” on lines 58 and 63. I’m not sure what you’re really trying to use “top” for, but checking for its starting value after you have subtracted from it is not going to work.

Add debugging to Başarılı() to print the value of “top” to the console to see for yourself.

Debug.Log(top.ToString());

@takixx we understand what you want your win and lose conditions to be. Both @Joe-Censored and I have explained what you have done wrong. Posting three separate posts re-explaining what you want your win condition and lose condition to be isn’t going to change that your implementation of it is not going to work.

How many balls you start with has nothing to do with your win condition You have already explained, win if 3 in, fail if 5 out. You don’t even need to set how many balls the user can throw because the outcome of a throw is either a miss or hit. Its impossible for them to throw more than .

why do you check if start is 7 EVERYTIME they throw. why do you detract 1 EVERYTIME they throw, why are you not even bothering to read my original post and just re-quote it back at me.

YES

if hit >= 3 THEN next level
else if miss >= THEN 5 fail level
else continue

NO

if hit >= 3 AND some other condition that never passes and doesn’t even matter anyway THEN next level
else if miss >= 5 AND some other condition that never passes and doesn’t even matter anyway THEN fail level
else continue

no need for his number 7, it doesnt do anything
4 misses plus 2 hits = 6, the final 7th throw is going to trigger either win or lose condition, why do you check 7

ALTERNATIVE

throws += 1
if (hits < 3 && throws == 7)
lose
else if (hits >= 3)
win
else
continue

You only need two variables not all three for win and lose condition. I’ve spent far too much energy on this.

I wanted to use 7 balls and use it until the last ball BUT
Now being a 3 ball basket and new stage
All balls are used until 3 balls are green
BUT
3 balls become green and instant new scene
I want 3 balls to be green then all to the last ball
THİS İS LİTERALLY
_**https://www.youtube.com/watch?v=jttMX8WxLh8**_

I’m not sure that I understand you clearly, but I’m guessing that you need something like this:

    private void Başarılı()
    {
        if (top <1) // used all the balls
        {
          if (sayac >= 3) { //won
            Debug.Log("Yeni Level");
            SceneManager.LoadScene(LevelPassed);
         
        }else
        { // lost
                Debug.Log("Level Başarısız");
                SceneManager.LoadScene(YenidenOyna);
        }
    }
}

Thank you man !!! My english is a litte bad I know.