On the basis of creating a good project directory
Import a third-party resource bundle in the project panel
Right-click---->import Package---->custom Package---->easy_touch.unitypackage
When the import is complete, you'll find that the menu bar has a hedgehog Team
Hedgehog Team---->easy Touch---->add Easy touch for C #
Inside the hierarchy panel.
Right-----> Create an empty node Joystick----> Add components to a node easy Joystick---->game view with joystick
Write a script to print out the dynamically selected coordinates of the joystick, which is called test_joystick, mounted under the joystick node, Joysticktouch (x, y) [-1, 1]
Script content:
usingUnityengine;usingSystem.Collections; Public classTest_joystick:monobehaviour {Easyjoystick joystick; //Use this for initialization voidStart () { This. Joystick = This. Getcomponent<easyjoystick>(); } //Update is called once per frame voidUpdate () {Debug.Log ( This. Joystick. Joysticktouch.x +":"+ This. Joystick. JOYSTICKTOUCH.Y); }}
Import Racing Resource F1 folder and basketball court plane map to resources directory
Create a Game_root node and drag the F1---->F1 car model preform into the game_root as its child nodes
Create a plane plane node as Game_root child nodes, the basketball court sticker dragged into the scene view of the plane, will automatically help us to generate a material ball and associated to the node, 3D nodes have to material to display content, 2D nodes as long as the picture can be.
The shader of the material plane is set to mobile diffuse
Node F1 child node if the material ball is not automatically associated, you need to manually drag the material ball to associate its child nodes
Drag a material ball of the same name into the element of the mesh renderer of the child node, and how many element are dragged several times
Restore the F1 node to a normal node gameobject---->break Prefab Instance
In order for the car to move, first give it a rigid body assembly rigidbody, set the mass mass to 50.
In order to collide, we also need to add a collider component to the car box Collider, set the size to x=2.5,y=0.5,z=8, adjust its position in center y=0.5
Create an empty node under the F1 node Phy_wheel, and then create a wheel node below Phy_wheel FL
Add Wheel Collider wheel Collider to FL, set the wheel mass mass to 2, spring Springs to 90, resistance damper to 45, and other wheel parameters as
1: Add car body collider;
2: Add 4 wheel collider;
3: Configure Wheel parameters:
Mass: Quality
Radis radius
Wheel dramping Rate Wheel rotation damping
Suspension Distance Suspension height, is the top and bottom of the wheel bumps up and down the amplitude distance;
Force app Point Distance suspension application points;
Center Wheel Collider Centre Point,
Suspension Spring Suspension Springs:
Sprint Elastic Damper Suspension Velocity damping
TargetPoint Suspension Center
Forward friction and lateral friction
Slip value of extermum slip previous friction curve
The extreme point of the previous friction curve of extermum points;
Asymptote slip forward progressive line slip value;
Asymptote point forward curve asymptotic line points;
Stiffness stiffness controls the multiple of the forward friction curve;
After configuring a wheel, then copy three wheels out, a four wheel fl,fr,bl,br, and then move the wheel node to the position of the four wheels in the corresponding model.
Create a script car mounted under the F1 node to control the wheel movement as the joystick moves
Car script content:
On the use of self-contained joystick and wheel collider in Unity5.5