Quantcast
Viewing latest article 1
Browse Latest Browse All 6

Answer by GuyTidhar

You can't do that exactly since the unity components are final and do not let you use inheritance and extend their capabilities. You can do one of 2 things: 1) Use a prefab - Create a game object. - Attach the rigidbody component to it. - Create a prefab in the Project window (right click mouse -> Create -> Prefab). - Drag the game object you've created on to the prefab you created. - Change the settings of the rigidbody on the prefab (not on the game object!). - Drag as many instances of this prefab to the hierarchy pane to create game objects that are copy of the prefab. - Now each time you change the prefab - the change effects all the instances of it which you have created. - Note: each setting you change on a game object which is connected to a prefab (was created from it), will not effect the other objects or the prefab (although in the GameObject menu you can select "Apply changes to prefab" when you have such a game object selected in order to... Apply those settings to the Master prefab. 2) Create a script that requires the component you wish to have defaults for and change the settings of the component you need during run time, like this (give a meaningful name to the script e.g. "RigidBodyExtended") @script RequireComponent(Rigidbody) // Duplicate any setting you wish to be able to change in run time public var useGravity = false; private var rigidBody : Rigidbody; function Awake() { // Grap the reference to the rigidbody rigidBody = GetComponent(Rigidbody); // Now you can use your own setting rigidBody.useGravity = useGravity; }

Viewing latest article 1
Browse Latest Browse All 6

Trending Articles