Page 1 of 1

Update GameObject value same as Prefabs for Reward

Posted: Tue Nov 28, 2023 8:27 am
by warlock34
Hello Tony,

I just try Quest Machine for Unity, I already finish the tutorial from youtube and read the document. I already try to apply it to my project and stuck at the reward system. First of all I'm sorry if my english was bad and I'm not good with programming.
May I ask if there is a way for my GameObject in the scene to update the value same as the Prefabs in UnityEvent ? Here is the picture and detail :

This is the Actions on Success quest, prefabs have value 100 points
Image

This is prefabs image where the value increase from 100 to 200 when quest Success
Image

This is GameObject where the value still 100 when quest Success, but change to 200 when I stop the game and play again.
Image

And here is the script :

Code: Select all

    public TextMeshProUGUI pointText;
    public TextMeshProUGUI crystalText;
    [SerializeField] public int totalPoints;
    [SerializeField] public int totalCrystals;

    void Start()
    {
        pointText.text = "P : " + totalPoints;
        crystalText.text = "C : " + totalCrystals;
    }

    void Update()
    {
        pointText.text = "P : " + totalPoints;
    }

    public void getPointsQuest(int value)
    {
        totalPoints += value;
    }

    //public int pointsQuest
    //{
        //get { return totalPoints; }
        //set
        //{
            //totalPoints += value;
        //}
    //}
Once again, thank you.

Re: Update GameObject value same as Prefabs for Reward

Posted: Tue Nov 28, 2023 12:28 pm
by Tony Li
Hi,

To assign a GameObject in the scene, choose "+" > "Scene Event" instead of "UnityEvent".

Re: Update GameObject value same as Prefabs for Reward

Posted: Tue Nov 28, 2023 8:05 pm
by warlock34
Hi Tony,

Thank you very much sir, it's work as I want, and thank you for your fast reply. It is a great asset for me who's bad a programming.

Once again, thank you sir.

Re: Update GameObject value same as Prefabs for Reward

Posted: Tue Nov 28, 2023 8:29 pm
by Tony Li
Glad to help!