So I have a vehicle which as a constant force applied to it. It is a 3d game, and I wish to make a system like this:
When the user touches the button, I want the car to steer (i.e rotate around a point to rotate the car 90 degrees).
For example, the red points would be transform positions, and when the user presses the button, the taxi rotates around that point, depending on how long they hold the button down for. So if the user held the button down, it would rotate the taxi around that point 10 degrees, and if they held it for two seconds, it would rotate by 20 degrees.
Hope this makes sense, and would love to hear any ideas about how this could work.
Add an EventTrigger component to the button. Add New Event Type and select Pointer Down.
Create a script that has a public function called TurnRightBy.
Have a float PressedFor and a bool isPressed declared at the top of the script. Then in TurnRightBy set the bool to true
In Update add Time.deltaTime to that float if the bool is true.
Add another New Event Type (Pointer Up) and another public function called TurnMeRight. Take the float PressedFor and round off to get your time held and apply your right rotation, set the bool to false and reset PressedFor to zero.
drag the script onto the button and in the button inspector drag the button onto the empty slots. The for Pointer Down select YourScriptName → TurnRightBy and for PointerUp select YourScriptName → TurnMeRight.
Do the same for the Left button but with a left turn.