Customizable Sets and Runtime Parts Change
Last updated
Last updated
Instead of presets, CustomVehicleController can use individually assigned parts. This ensures a safe modification to the parts the vehicle is using without affecting other vehicles.
Either in the inspector or editor window turn off the "Use Preset" toggle.
Assign parts either in the inspector or editor window. When a controller is selected, changes to the parts object fields in the editor are applied to the controller as well.
Changes to the parts that the CustomVehicleController is using can be made from an external script.
Get a reference to the CustomVehicleController script
Have a reference to some vehicle part scriptable object that you wish to change to.
Call the "SetNewPartToCustomizableSet" from the controller script and pass the desired scriptable object. This method expects a scriptable object that extends the IVehiclePart interface (every vehicle part does) and, optionally, a boolean for whether the part is front or rear (in the case of suspension and tire parts).
You can safely change between presets and customizable sets at runtime as long as neither has Null object fields.