Question by
Krystian223 · Jul 30, 2021 at 11:08 AM ·
buttontriggernpcontriggerstayshop
How to make click event so when click button points get decreased?
So, I made when you get close to NPC and click "E" UI is showed and you can but things. My buttons have OnClickEvent "ButItem()". Anyone knows how to fix that? Points dont get decreased.
GameManager gameManager;
public int value;
void Start()
{
gameManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>();
}
// Update is called once per frame
public void BuyItem()
{
gameManager.skullPoints -= value;
}
GameManager script:
public int skullPoints = 0;
Comment
Your answer
Follow this Question
Related Questions
Continuous action while pressing UI Button 1 Answer
How to get "on trigger enter"( or exit) to only react to a specific tag 1 Answer
How can I make a song play when an NPC gets within a certain range of the player? 2 Answers
how to separate differents triggers 1 Answer
How to show dialogue when triggered by collision with npc collide box? 0 Answers