wiki.sine.space | sinespace

Difference between revisions of "Vehicles"

From wiki.sine.space
Jump to: navigation, search
Line 1: Line 1:
'''Please notice there are two versions of script for Vehicles: the old ones are the scripts like "car physics", "car vehicle", which are obsolete; the new vesion is one script called "Modular Vehicle", it combines all kinds of vehicle together(land, hover, boats) so you can adjust this one script for all vehicle settings. The new version resolved many bugs of the old version, so we recommand to use the new one.''' We will still keep the tutorial of old version in other pages, you can always check them if you need.<br />
+
'''Please notice there are two versions of script for Vehicles: the old ones are the scripts like "car physics", "car vehicle", which are obsolete; the new vesion is one script called "Modular Vehicle", it combines all kinds of vehicle together(land, hover, boats) so you can adjust this one script for all types of vehicle settings. The new version resolved many bugs of the old version, so we recommand to use the new one.''' We will still keep the tutorial of old version in other pages, you can always check them if you need.<br />
  
Note: This page is updating to new version so there may be some place incomplete during this moment.
+
Note: This page is still updating so there may be some place incomplete during this moment.
  
== Simple guide for a land vehicle: Red Truck ==
+
== Simple guide for a land vehicle ==
  
'''Truck model from asset store, consists of empty gameobject with five dependent meshes; the truck body proper and four wheels.'''<br />
+
To start create a land vehicle, you should find yourself a vehicle model. <br />  
''all else you will see on the vehicle is added during the 'scripting' process.''<br />
+
'''To prepare a model for vehicle, whether you want create one using MAYA or 3DMAX or Blender, or find a model from Unity asset store, there are somethings you should pay attention to:'''<br />
[[File:Redtruck.png]]<br />
+
''Make sure the wheels are splited from the vehicle body. Some vehicle in asset store has a single FBX file combined all the things together, which makes the next steps quite impossible if we don't do something to the model.''<br />
This is not a perfect vehicle. It's 'alright'. There is more that could be done with it, which Adam covers in the related Artist's Masterclass. It is, however a decent reference vehicle, for making vehicles that behave in a more or less expected fashion, vis a vis real life (tm) vehicles.<br />
+
 
To prepare a model for vehicle, whether you want create one using MAYA or 3DMAX or Blender, or find a model from Unity asset store, there are somethings you should pay attention to:<br />
+
As an example, we choose a simple low-poly car in asset store(which the server can proceed faster), like this:<br />
1. Make sure the wheels are splited from the vehicle body. Some vehicle in asset store has a single FBX file combined all the thing together, which makes the next steps quite impossible if we don't do something to the model.<br />
+
[[File:ToonCar.png]]<br />
2. The edge of the wheels should be as smooth as possible. Some low polygons models cannot act very well on our vehicle system.<br />
+
 
 +
You can always choose a vehicle more realistic and complex, but there may be more details need to adjust on your own. <br />
 +
 
 +
'''Preparation:'''<br />
 +
You can find that the objects for the vehicle are like this:<br />
 +
[[File:Objects.png]]<br />
 +
Carbody is the body of the car, not include the wheels.<br />
 +
Seat is an empty object here, it defines where your avatar sit in the car. <br />
 +
The wheel group contains the 4 wheels, and the wheel collider group contains the wheel colliders for each wheel.<br />
 +
''The positions of the wheel colliders need to adjust individually, so they should be created seperately from the wheels. You can do it by creating an empty gameobject then add a component of wheel collider, duplicate 3 more, rename them.''<br />
  
Preparation:
 
When you have your vehicle model ready, follow the steps below:
 
1. Add wheel collider for each wheel. The value will be set later.
 
2. Add a collider to the vehicle body. A simple box collider which covers most of the vehicle body is enough. It is used for clickable item trigger. If you find your vehicle cannot be activated by click, check the collider here you use.
 
<br /><br />
 
NOTE:<br />
 
As it turns out, on 'realistic' terrain, this truck drives a bit like a moon buggy. For a more realistic experience, set 'Max Speed' to '15'; 'Mass' to '7500' and adjust the rear wheels such that each has 'Forward Torque' to '750' and 'Backward Torque' to '500'. On the wheel colliders (all four wheels), set 'Suspension Spring' to '6' and 'Damper' to '10'.
 
<br />
 
<br />
 
 
----
 
----
 
<br />
 
<br />
This is the basic modular vehicle component for the red truck. There's a few more bits to it off the bottom, but they do not apply to this vehicle.<br />
+
Choose the parent object of the whole car, then add a script named "Modular Vehicle". A rigidbody component will be added automatically as well.<br />
[[File:Redtruckmodularvehiclecomponent.png]]<br />
+
As a simple guide, it will only show you how to make a car which can be driven in the game. There's a few more stuffs in the script settings but we will ignore them here.<br />
 +
[[File:Modular vehicle.png]]<br />
 +
Set the "Seat Root" with the seat gameobject, and Ride Animation you can get it from [https://www.mixamo.com Mixamo] freely.<br />
 +
The Mass will be the weight of your car, the value here only shows an example.<br />
 +
''Note: there is also a Mass property in Rigidbody component, change it to the same value.'' <br />
 +
The Center of gravity concerns the stability of the vehicle. If you want to create a big truck, make it a little lower may be better(like (0, -1.25, 0)), otherwise just leave it to default.<br />
 
<br />
 
<br />
These are the 'core forces' settings. They configure the vehicle 'overall'. Everything else is pretty much 'per wheel'. Note that the first two wheels are right and left rear.<br />
+
These are the 'core forces' settings. They configure the vehicle 'overall'. Everything else is pretty much 'per wheel'. <br />
[[File:Redtruckmodvehcompcoreforces.png]]<br />
+
[[File:Core forces.png]]<br />
 
<br />
 
<br />
This is a representative rear wheel. The other rear wheel looks identical, it's just on the other side.<br />
+
Our example is a regular 4 wheels car, so we set the number of wheels as 4. If you are creating a vehicle with different number of wheels, just enter the wheel number here -- and make the same number of wheel colliders.<br />
[[File:Redtruckrearwheel.png]]<br />
+
[[File:Wheels.png]]<br />
 +
This is a representative front wheel. The other uses the same values with its own transform and collider.<br />
 +
[[File:Wheel0.png]]<br />
 
<br />
 
<br />
This is a representative front wheel. As with the rear wheels, the other is identical.<br />
+
This is a representative rear wheel. Same for the values, it's just on the other side.<br />
[[File:Redtruckfrontwheel.png]]<br />
+
[[File:Wheel2.png]]<br />
 
<br />
 
<br />
 +
In this example, the front and rear wheel is in different size(it's a race car, somehow), so the mass and radius are different. For a normal car, they might be the same value.<br />
 
This is the collider for the rear wheel. It will be the same on the other side. Differences are in the name and position on the model. This applies generally to all the wheel elements.<br />
 
This is the collider for the rear wheel. It will be the same on the other side. Differences are in the name and position on the model. This applies generally to all the wheel elements.<br />
[[File:Redtruckrearwheelcollider.png]]<br />
+
[[File:Wheelcollider rear.png]]<br />
 
<br />
 
<br />
 
This is the collider for the front wheel.<br />
 
This is the collider for the front wheel.<br />
[[File:Redtruckfrontwheelcollider.png]]<br />
+
[[File:Wheelcollider front.png]]<br />
 +
After set the values, you should adjust its position and size manually. Make the radius match the size of wheel then modify the collider's postion to the center of the tire. Like this: <br />
 +
[[File:Wheelcollider position.png]]    [[File:Wheelcollider position2.png]]<br />
 
<br />
 
<br />
Finally there's a trail rendering component for making tracks<br />
+
If you want to add tire track, here's a image from the old version, but it's always the same way.<br />
 
[[File:Redtruckrearwheeltrailrenderer.png]]<br />
 
[[File:Redtruckrearwheeltrailrenderer.png]]<br />
 
<br />
 
<br />
 +
Finally, add a box collider in the parent object, make sure it doesn't have conflict with the wheel colliders.<br />
 +
[[File:Car boxcollider.png]]<br />
 +
Forget this will make your vehicle cannot trigger the clickable events(which equals cannot drive it). <br />
 +
 +
<br />
 +
Now you can add a virtual good component to the parent object to upload and test it. <br />
 +
 +
----
 
<br />
 
<br />
There are four types of vehicles in the Space virtual world platform;
+
''The hover points and boat forces are for hover type and boat type, which is still under testing now.''<br />
  
 
== Hover ==
 
== Hover ==

Revision as of 09:37, 20 November 2018

Please notice there are two versions of script for Vehicles: the old ones are the scripts like "car physics", "car vehicle", which are obsolete; the new vesion is one script called "Modular Vehicle", it combines all kinds of vehicle together(land, hover, boats) so you can adjust this one script for all types of vehicle settings. The new version resolved many bugs of the old version, so we recommand to use the new one. We will still keep the tutorial of old version in other pages, you can always check them if you need.

Note: This page is still updating so there may be some place incomplete during this moment.

Simple guide for a land vehicle

To start create a land vehicle, you should find yourself a vehicle model.
To prepare a model for vehicle, whether you want create one using MAYA or 3DMAX or Blender, or find a model from Unity asset store, there are somethings you should pay attention to:
Make sure the wheels are splited from the vehicle body. Some vehicle in asset store has a single FBX file combined all the things together, which makes the next steps quite impossible if we don't do something to the model.

As an example, we choose a simple low-poly car in asset store(which the server can proceed faster), like this:
ToonCar.png

You can always choose a vehicle more realistic and complex, but there may be more details need to adjust on your own.

Preparation:
You can find that the objects for the vehicle are like this:
Objects.png
Carbody is the body of the car, not include the wheels.
Seat is an empty object here, it defines where your avatar sit in the car.
The wheel group contains the 4 wheels, and the wheel collider group contains the wheel colliders for each wheel.
The positions of the wheel colliders need to adjust individually, so they should be created seperately from the wheels. You can do it by creating an empty gameobject then add a component of wheel collider, duplicate 3 more, rename them.



Choose the parent object of the whole car, then add a script named "Modular Vehicle". A rigidbody component will be added automatically as well.
As a simple guide, it will only show you how to make a car which can be driven in the game. There's a few more stuffs in the script settings but we will ignore them here.
Modular vehicle.png
Set the "Seat Root" with the seat gameobject, and Ride Animation you can get it from Mixamo freely.
The Mass will be the weight of your car, the value here only shows an example.
Note: there is also a Mass property in Rigidbody component, change it to the same value.
The Center of gravity concerns the stability of the vehicle. If you want to create a big truck, make it a little lower may be better(like (0, -1.25, 0)), otherwise just leave it to default.

These are the 'core forces' settings. They configure the vehicle 'overall'. Everything else is pretty much 'per wheel'.
Core forces.png

Our example is a regular 4 wheels car, so we set the number of wheels as 4. If you are creating a vehicle with different number of wheels, just enter the wheel number here -- and make the same number of wheel colliders.
Wheels.png
This is a representative front wheel. The other uses the same values with its own transform and collider.
Wheel0.png

This is a representative rear wheel. Same for the values, it's just on the other side.
Wheel2.png

In this example, the front and rear wheel is in different size(it's a race car, somehow), so the mass and radius are different. For a normal car, they might be the same value.
This is the collider for the rear wheel. It will be the same on the other side. Differences are in the name and position on the model. This applies generally to all the wheel elements.
Wheelcollider rear.png

This is the collider for the front wheel.
Wheelcollider front.png
After set the values, you should adjust its position and size manually. Make the radius match the size of wheel then modify the collider's postion to the center of the tire. Like this:
Wheelcollider position.png Wheelcollider position2.png

If you want to add tire track, here's a image from the old version, but it's always the same way.
Redtruckrearwheeltrailrenderer.png

Finally, add a box collider in the parent object, make sure it doesn't have conflict with the wheel colliders.
Car boxcollider.png
Forget this will make your vehicle cannot trigger the clickable events(which equals cannot drive it).


Now you can add a virtual good component to the parent object to upload and test it.



The hover points and boat forces are for hover type and boat type, which is still under testing now.

Hover

PENDING

Boat

PENDING

Tutorial for obsolete vehicle script

Land vehicles Aircraft and Gliders Hover Vehicles Watercraft and Boats