Progress xp bar

Agreed.

What’s your question?

Where are you stuck?

Why is there a poll?

Why should we put more effort into responding to you than you put into asking for assistance?

We need more information.

4 Likes

Also… Avoid taking pictures of your screen and use the screenshot tools that your computer already has instead.

2 Likes

So, no scripts?:slight_smile:

That’s right, you didn’t post any.

2 Likes

I will repeat myself:

Or should I google that for you?
https://lmgtfy.com/?q=unity+progress+bar+tutorial

I am not really sure what you want / are looking for but perhaps this will help: LINK
Point 5 and 6:

Thank you!!!

And they run off into the ether never had learning anything except that begging works. Forever destined to be “that developer” who doesn’t solve problems, but rather gets others to solve problems for them.

4 Likes

Most of those “developers” never release anything either, or they release junk that nobody plays.

So it may go in the indie game dev world…

but in the enterprise world I work side by side with them all day every day…

Lmao for real tho.

Next week: How do I get my character to do damage? Anyone?

1 Like

ok,ok I got it!! As I said, I just started to learn about scripts and games (or I’m saying this now), and for me the best way to learn something is by practice, so I’m still a ,baby" in this. I tried to do it by myself, but it doesn’t work. I’m not sure but I think I have to use float, which I’m still trying to figure it out how it works. The idea of my first game is to click the Buckets button on the screen and gaining xp by doing that, which is shown on the slider (xp bar), Until now I learnt just how to count the clicks and show it on a text display. The problem is that the fill doesn’t change its value by clicking the button.

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

public class BucketsButton : MonoBehaviour {

    public Slider sliderInstance;
    public static int BucketsCount;

    void Start()
    {
        sliderInstance.minValue = 0;
        sliderInstance.maxValue = 100;
        sliderInstance.wholeNumbers = true;
       
    }
    public GameObject textBox;

  

    public void ClickTheButton ()
    {
        BucketsCount += 1;
       
    }
    public void SliderIncrease ()
    {
        sliderInstance.value = BucketsCount;
    }
}

This is the appropriate way to ask a question.

Explain your problem - check
Show code that you currently have - check
Demonstrate to the community you’ve put in effort - check

If I’m following correctly, when you say: “The problem is that the fill doesn’t change its value by clicking the button.” Are you still having problems?

If so, when/where do you call both ClickTheButton and SliderIncrease?

Personally I’d suggest ‘SliderIncrease’ should actually be called something like “UpdateSliderDisplay” or something since it doesn’t actually increase anything (and could decrease depending on what BucketsCount is)… but rather its job is to update the slider (display) with the current BucketCount.

Similarly the ‘ClickTheButton’… that’s more what gets done when click. It increases the BucketCount. And it probably should call ‘SliderIncrease/UpdateSliderDisplay’ so the display is up to date always.

But yeah… where do these methods get called?

thanks, but still not working :confused:
Here is what I did:
first, changed the code as you said
created a “GameLogic” folder
moved the script, slider instance and button in it
put the “GameLogic” as a game object in Slider and selected the Dynamic float-“UpdateSliderDisplay” function
put the “GameLogic” as a game object in Button and selected the ClickTheButton () function
and the script looks now like this:


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

public class BucketsButton : MonoBehaviour {

    public Slider sliderInstance;
    public static int BucketsCount;

    void Start()
    {
        sliderInstance.minValue = 0f;
        sliderInstance.maxValue = 100f;
        sliderInstance.wholeNumbers = true;
        sliderInstance.value = 20f;
    }
    public GameObject Button;

   

    public void ClickTheButton ()
    {
        BucketsCount += 1;
        
    }
    public void UpdateSliderDisplay(float value)
    {
        Debug.Log (sliderInstance.value += BucketsCount);
    }
}

Of course it’s still not working, because my post wasn’t solving your problem. My post had a question in it.

You didn’t answer that question…

When and where do you call ‘ClickTheButton’ and/or ‘UpdateSliderDisplay’?

Those methods are what update your BucketCount, and your slider, respectively. If no other code calls them, they never do anything. You need to call them somewhere. Where, if anywhere, do you call those functions?

So should I introduce an API?

You should answer my question.

1 Like

Call them to a class