02.04 Adding components to the prefab

Components can be scripts, rigidbodies (they add physics to the object) and more. We will add some to make our object more reactive.

Adding rigidbody component

On the right in the Inspector window, press Add Component->Rigidbody like this:

Once it's added, change Collision Detection from Discrete to Continous. You can also modify the Mass (it's in kilos) and Drag.

Adding network components

Next, add Network Transform (Unreliable) and Network Rigidbody (Unreliable). Make sure the Sync Direction is set to Client to Server!

These will also automatically add a Network Identity component in your project.

Collapsing components

You can collapse all of the components by clicking on their title so they dont take up space:

Firework components

Add the Firework Mesh component and drag the model from the Hierarchy into Spawn Mesh Reference. Also select the Object physics sound surface to whatever you want by clicking the dot on the right side. It'll change the sound of the prop when it's falling, sliding etc. You can view the documentation for more details: Firework Mesh (Component)

Adding collision

Add the Mesh Collider component and tick the Convex checkbox. Remember, the smaller the scale of the object is - the more accurate the convex collision will be. For now it's very inaccurate as the scale is 100, but for now we won't worry about that - we'll fix that in the next chapter. You should see a green wireframe that shows the object collision - if you don't, make sure you have gizmos on.

You can collapse this component as well, and now we're done with all the components we need for a prop.

Last updated