I’m working on a game where a player can purchase and place towers, however I cannot seem to find how to make a global variable where upon tower placement cash can be deducted. I have looked at some other questions related to this topic, but have still yet to find something that works.
why not put player cash in the PlayerState or PlayerController? or maybe the GameState?
That’s what I did, but I’m not able to subtract from that variable when I build a tower - unless I’m missing something very obvious.
you should be able to getPlayerController and cast to your custom player controller type from almost anywhere.
you should usually avoid global variables and try to have objects contain variables.