Line 128: | Line 128: | ||
Drop the Virtual Camera into the Primary Camera slot on the Modular Vehicle Component. There are slots here for secondary cameras such as reverse cameras if you wish to add them. | Drop the Virtual Camera into the Primary Camera slot on the Modular Vehicle Component. There are slots here for secondary cameras such as reverse cameras if you wish to add them. | ||
− | == | + | == Master Class == |
Thank you for following this sinespace Tutorial. | Thank you for following this sinespace Tutorial. | ||
− | If you need some extra guidance, the tutorial is available as a Master Class on Youtube [ | + | If you need some extra guidance, the tutorial is available as a Master Class on Youtube [https://www.youtube.com/watch?v=Sd7SmwF_X8U here] |
Start with a new scene, we'll be using this to test the vehicle The example world here was built with World Machine, you can use Wold Machine to generate your own environment too.
Firstly we'll be using the Modular Vehicle Component. This sine editor component allows us to tweak and modify and a vast array of settings and functions that are relevant to how vehicles handle within sinespace. You'll be able to get most different types of vehicles operating using this component with none of your own scripting needed.
We're now going to add our car body into the world. For this tutorial, we're using a buggy.
If you're building your own models and textures, remember the wheels will need to be separated from the main body and separate from eachother in order to provide steering animations The Modular Vehicle Component allows for steering movement independent of the body and the control of different settings for each wheel.
Next we're going to add the Mesh collider to the Buggy, you can use other coliders if you wish, but for this tutorial, we'll be sticking to the Mesh. The Convex mesh is being used in this example for simplicity and processing speed.
Note: This will auto add the Ridgedbody component too, this component you should be familiar with, it tells unity that the object is dynamic and is affected by the physics system.
Note: Drag and Mass in the RidgedBody component will be overridden by the settings in the Modular Vehicle Component
Select a wheel on your vehicle and then create and Empty Child Object, now move the child to be under the main GameObject in the Hierarchy. Do this for each wheel on your vehicle.
Note: Doing this by this method places the colliders we’re creating in roughly the right spots so we don’t have to do as much repositioning later.
Once we have all the new child objects created, select them all and add the Wheel Collider component to the Inspector. You should now see green circles appearing in the Scene window, these represent how the physics engine will consider the wheels of the Car, the little sphere at the bottom is the contact point, this is where the collider expects to touch the ground.
In this example, we’re going to have to adjust the bounds a bit
Note: this doesn’t need to be exact, getting as close as possible will look better though
We’re going to use the following settings:
Note: You only need to setup 1 collider and the settings will copy across the rest
Attach one of the back Wheel mesh to Wheel Visual Transform under Wheels section in the Modular Vehicle Component
Note: The position information from the collider will be used to position the visual transform, so keep them aligned
For this example, we’re going to set the forward torque to 800 and the backward torque to 300, bear in mind that the force is in newton meters
Now for the front wheels
You will need to mirror the setting changes for both Element 2 & 3
Note: This will now the player where to sit, if one is not set, the player will just sit in the middle of the vehicle.
Next we're going to be setting up the camera configuration for our vehicle. Create a new Empty Child and attach a Cinemachine Virtual Camera Component
Now we’re going to add a Cinemachine brain to the Main Camera so we can preview the camera
Moving back to the GameObject Camera we created
Now if you switch to the Game View, you’ll see the camera scope, the black box is the area where the camera won't try to re-orientate, the blue or red area is where the camera will try to reorientation from
Default priority is 10, we’re going to set it to 10000 so none of the sinespace cameras will interfere with it
Drop the Virtual Camera into the Primary Camera slot on the Modular Vehicle Component. There are slots here for secondary cameras such as reverse cameras if you wish to add them.
Thank you for following this sinespace Tutorial. If you need some extra guidance, the tutorial is available as a Master Class on Youtube here