Move gameObject on UI Button Press
Good day,
So what I want to have is when I press my "GasPedal" button, the gameObject "car" moves forward. When I press the "BrakeReverse" button, the gameObject "car" moves backward. I know how to do this with GetKey but I can't seem to find a way to do this with a UI Button.
Can somebody help me? I had this setup but I don't think I'm doing it right there.
Answer by Statement · Oct 24, 2015 at 12:43 AM
Your problem is very similar to the solution for another question I answered.
Instead of having one button as in my example, have two. One of the buttons EventTrigger should route to functions PressBrake and ReleaseBrake and the other buttons EventTrigger should route to function PressGas and ReleaseGas. Obviously you need to create those functions yourself but it should look pretty similar to the answer I provided there.
Thanks a lot! I've been looking for a way to do this for ages now, pity I never came across the linked question...
This was the only part for my project I still had left to understand: Thanks, again!