Update GameObject value same as Prefabs for Reward

Announcements, support questions, and discussion for Quest Machine.
Post Reply
warlock34
Posts: 2
Joined: Tue Nov 28, 2023 7:36 am

Update GameObject value same as Prefabs for Reward

Post 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.
Attachments
prefabs.png
prefabs.png (49.38 KiB) Viewed 4588 times
gameobject.png
gameobject.png (122.38 KiB) Viewed 4588 times
action.png
action.png (20.75 KiB) Viewed 4588 times
User avatar
Tony Li
Posts: 20632
Joined: Thu Jul 18, 2013 1:27 pm

Re: Update GameObject value same as Prefabs for Reward

Post by Tony Li »

Hi,

To assign a GameObject in the scene, choose "+" > "Scene Event" instead of "UnityEvent".
warlock34
Posts: 2
Joined: Tue Nov 28, 2023 7:36 am

Re: Update GameObject value same as Prefabs for Reward

Post 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.
User avatar
Tony Li
Posts: 20632
Joined: Thu Jul 18, 2013 1:27 pm

Re: Update GameObject value same as Prefabs for Reward

Post by Tony Li »

Glad to help!
Post Reply