Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Health, hunger, and hygine values not working as scriptable objects

Discussion in 'Scripting' started by vivianindatub, May 10, 2021.

  1. vivianindatub

    vivianindatub

    Joined:
    Apr 23, 2021
    Posts:
    71
    So I created some player stats as scriptable objects and use On Enable to make them decrease with time
    I created health hunger and hygine as 3 separate scriptbale objects in asset files
    Then I created a UI script to have the values display in game mode,
    I hook everything up in inspector -- BUT the values are not changing at all- they're always stuck at 100 (max value). What am I missing here?
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    OnEnable will generally be called once.

    Do you intend to use Update()? That's usually how things are done over time.

    Here is some timing diagram help:

    https://docs.unity3d.com/Manual/ExecutionOrder.html