Calling "OnUse()" from script?
Posted: Wed May 25, 2022 2:47 pm
Hi,
I'm working on some touch control for my game and I wanted to make a button on screen that would basically trigger the "OnUse()" fonction to interact with objects (opening doors, treasure, etc).
I tried simply calling ProximitySelector.UseCurrentSelection() when clicking on the button, but for some reason I get an error and found out that the 'currentUsable' variable is null. What's weird is that if I make a debug.log in ProximitySelector's Update method to write the value of currentUsable in the console, I see that it's not null.
The OnUse() works when I use the keyboard key, but won't work when I try calling it with a button on screen. Can you help me with this? Thanks!
I'm working on some touch control for my game and I wanted to make a button on screen that would basically trigger the "OnUse()" fonction to interact with objects (opening doors, treasure, etc).
I tried simply calling ProximitySelector.UseCurrentSelection() when clicking on the button, but for some reason I get an error and found out that the 'currentUsable' variable is null. What's weird is that if I make a debug.log in ProximitySelector's Update method to write the value of currentUsable in the console, I see that it's not null.
The OnUse() works when I use the keyboard key, but won't work when I try calling it with a button on screen. Can you help me with this? Thanks!