Login

Fancade Wiki

Updated How to make a car.md (markdown)

... ...
@@ -4,7 +4,7 @@ In this tutorial, we will use constraints to attach the wheels to the car, and s
4 4
5 5
By the end of the tutorial you will have a car like this:
6 6
7
[car.gif]
7
[[/uploads/tutorial-car-0.gif]]
8 8
9 9
## Modelling the car
10 10
... ...
@@ -14,22 +14,24 @@ I will use the Physics Box as a template. You can use any block, but the Physics
14 14
15 15
You can find the physics box in the 'Templates' category in the inventory. It doesn't look much more like a car than it looks like an orange cube with square holes on every side. Let's model it to look more recognizable!
16 16
17
[[/uploads/tutorial-car-1.jpg]]
18
17 19
Place the physics box down on the ground, tap the pencil icon on the lower right corner, tap OK, and then you can begin modelling your car.
18 20
19 21
This is the car that I made:
20 22
21
[image of car]
23
[[/uploads/tutorial-car-2.jpg]]
22 24
23
It's the greenest car you have ever seen. (Also given that it is powered digitally by a phone, it is also incredibly friendly for the environment!)
25
It's the greenest car you have ever seen. (Also given that it is powered digitally by a single phone, it is also incredibly friendly for the environment!)
24 26
25 27
A few important points before you model your car:
26 28
Make sure your car is facing in the positive z-direction, as shown in the image below. This will be important later, when setting up constraints for the wheels.
27 29
28
[image of car direction]
30
[[/uploads/tutorial-car-3.jpg]]
29 31
30 32
Make sure the wheels are separated from the car itself. Voxels will glue together when they are next to each other; not ideal for wheels that need to be spinning on their own! To remove the glue between the car and the wheels, use the glue tool in the voxel editor:
31 33
32
[car-removing-glue.gif]
34
[[/uploads/tutorial-car-4.gif]]
33 35
34 36
## Modelling the wheels
35 37
... ...
@@ -37,7 +39,8 @@ We will also create a wheel object. The reason we have to do this is because the
37 39
38 40
It is important that you use the 'Physics Sphere' object as a template for your wheel. Physics spheres are special, because their colliders are spheres instead of boxes. The size of this wheel doesn't matter, but I made mine a 2x2x2 cube:
39 41
40
[image of wheel object]
42
[[/uploads/tutorial-car-5.jpg]]
43
[[/uploads/tutorial-car-6.jpg]]
41 44
42 45
## Adding constraints to the car
43 46
... ...
@@ -49,23 +52,22 @@ Select your car, then tap on the button on the bottom left. The top of the car w
49 52
50 53
First, I will assign an object variable called 'Car'. I will drag it's wire to the car.
51 54
52
[car-assign-object.gif]
53
54
I will do the same for each of the four wheels (front right, front left, rear right, rear left). These can sometimes be harder to connect because of the tiny wheels. If the wire connection shows a pink arrow pointing at the wheel, great job! If you see a large pink cube instead, you have created a script input by mistake, and you need to reposition the wire until you get the arrow.
55
[[/uploads/tutorial-car-7.jpg]]
55 56
56
[image of wheel variables assigned]
57
I will do the same for each of the four wheels (front right, front left, rear right, rear left). These can sometimes be harder to connect because the wheels are quite tiny. If the wire connection shows a pink arrow pointing at the wheel, great job! If you see a large pink cube instead, you have created a script input by mistake, and you need to reposition the wire until you get the arrow.
57 58
58
[image of right and wrong ways to connect wires]
59
[[/uploads/tutorial-car-8.jpg]]
60
[[/uploads/tutorial-car-08.jpg]]
59 61
60 62
Next, I will add each of the 4 wheels to a list. This will be useful for creating constraints for all wheels at the same time.
61 63
62
[image of list]
64
[[/uploads/tutorial-car-10.jpg]]
63 65
64 66
With all that setup done, we can finally configure the constraints for our wheels!
65 67
66 68
I create a loop that loops 4 times, once for each wheel. The W variable holds the current wheel number (0, 1, 2 or 3).
67 69
68
[image of loop]
70
[[/uploads/tutorial-car-11.jpg]]
69 71
70 72
The next step is to hide our 'fake', square wheels with our circular, real ones.
71 73
... ...
@@ -75,11 +77,11 @@ Then, use Create Object to create a copy of the wheel you made earlier, and use
75 77
76 78
The wheels are small, so they can be quite light. Therefore I give the wheels some extra mass. I also increase the friction of the wheels to 1, to make them less slippery.
77 79
78
[image of script replacing wheels]
80
[[/uploads/tutorial-car-12.jpg]]
79 81
80 82
If you tap play now, you should see that your wheels have been successfully replaced! However, they are all disconnected from the car.
81 83
82
[car-detached-wheels.gif]
84
[[/uploads/tutorial-car-13.jpg]]
83 85
84 86
Let's attach them to our car with constraints!
85 87
... ...
@@ -87,17 +89,17 @@ Find the 'Add Constraint' block, found in the physics category in the inventory.
87 89
88 90
The 'Base' of our constraint will be the car object. The 'Part' will be our wheel!
89 91
90
[image of constraint script]
92
[[/uploads/tutorial-car-14.jpg]]
91 93
92 94
There! Now our wheels are properly attached to the car!
93 95
94
[image of wheels attached to car]
96
[[/uploads/tutorial-car-15.jpg]]
95 97
96 98
The wheels are very stiff, and they cannot rotate yet.
97 99
98 100
To fix this, we need to define the [Linear Limits] and [Angular Limits] of the constraint. These blocks define the freedom/restriction of movement of the constraint. We want the constraint to move up and down, and we also want to spin the constraint along the wheel axle. To do that, we can configure the wheels like so:
99 101
100
[image of linear and angular limits]
102
[[/uploads/tutorial-car-16.jpg]]
101 103
102 104
Finally, we will add this constraint to a list so we can use it later. I will save the constraint to a list called Cs (short for constraints) and put it at index W (the wheel number).
103 105
... ...
@@ -105,15 +107,17 @@ Finally, we will add this constraint to a list so we can use it later. I will sa
105 107
106 108
Our wheels can now move up and down, but we still haven't added suspension to our car, so it falls to the earth.
107 109
110
[[/uploads/tutorial-car-17.gif]]
111
108 112
Let's give our wheels some springy action!
109 113
110 114
We begin a new loop. This loop will run at every frame. For each constraint, we will add a linear spring to it.
111 115
112
[image of linear spring script]
116
[[/uploads/tutorial-car-18.jpg]]
113 117
114 118
You can configure the spring and damping parameters until you get something you like! I found that these values work best for my car.
115 119
116
[car-spring.gif]
120
[[/uploads/tutorial-car-19.gif]]
117 121
118 122
Look at that! Our car is nice and bouncy now!
119 123
... ...
@@ -121,19 +125,18 @@ We are really far into the tutorial, but the car still can't drive. Let's fix th
121 125
122 126
Underneath the Linear Spring script, add a [Linear Motor] script, like this:
123 127
124
[image of linear motor script]
128
[[/uploads/tutorial-car-20.jpg]]
125 129
126 130
And again, you can configure the speed and force values to your liking. Speed is the top speed of the car, and force is similar to what you would call horse-power in the real world.
127 131
128
[car-motor.gif]
132
[[/uploads/tutorial-car-21.gif]]
129 133
130 134
At last, the engine is running! Actually, it will always be running, without ever stopping. How about we add some simple touch controls?
131 135
132 136
Let's reconfigure the script:
133 137
134
[image of touch controlled motor]
135
136
[car-motor-controlled.gif]
138
[[/uploads/tutorial-car-22.jpg]]
139
[[/uploads/tutorial-car-23.gif]]
137 140
138 141
We can now speed up and slow down at will. However, we cannot turn yet.
139 142
Fancade Wiki