Saturday, March 28, 2009

Unity3D: PhysicMaterial

The first thing I wanted to learn was how to use the PhysicMaterial and here's what I've found out.

To make a new PhysicMaterial you:

1. Assets > Create > Physic Material
2. I assume you have at most a sphere. If you do then click on it and look in the inspector. Under Sphere Collider you can find a Material drop down. Select the Physic Material you just created
3. There's a bunch of values you can tune and I'll leave that to the individual to mess around with. You can also read more about it in the documents

Now to access it through script you simply do the following:

this.GetComponent(Collider).material.bouncyness = 0;


or

colider.material.bouncyness = 0;


You can now script these values anyway you like. I had some help from the people on the unity3d irc channel. Thanks!

that's it! Now you can setup a project and bounce some balls around. Oh the joy of unity!

No comments: