Today, to share, how to do a virtual joystick to realize the movement of the object and the specific operation, the following is a simple through the virtual joystick can realize driving motorcycle, [PS: because the project code is more, maybe articles is not enough comprehensive speak clearly, I hope you can forgive me,
Restricted by postings of, code should not be all, if you want to source or resources, you can directly add QQ: 575561285]
All right! Please donate, directly into the theme!
1. New unity3d project, and it is reasonable to build a scenario, the import need resources, for example, my side will import some model of the motorcycle,
2. The first concern is the motorcycle itself attribute set, and then you can give them hang up the script, attributes: Pro_bike 5. Js, voice control: Bike_sound. Js, brake control: Skid Marks. Js.
And then the specific code is as follows:
1) Pro_bike 5. Js:
(2) Bike_sound. Js:
(3) Skid Marks. Js:
[script parameter Settings as shown in figure]
3. Next, we need in the scene, create a GameObject gameScenario game object, as the entire game control center, and the additional speed control in gameScenario object: Speedometer. Js
Control the whole game object: controlHub. Cs
1 the Speedometer. Js:
(2) controlHub. Cs:
4. The camera in the scene to follow and switch classes: camSwitcher. Cs;
5. When it comes to this step is critical, it is through the GUI to make virtual joystick, virtual joystick control class: mobileControls. Cs;
6. The last run directly see the effect, [PS: HAHA! Free hands-on practice is also interesting]