Open JustInvoke opened 7 years ago
Actually, for setup a new vehicle, its quite difficult to setup (like setup animation curve ... ). If have loading presets, would be great to setup.
Hi RandomationsGames,
How about with this issue, i have problems when create new vehicles, i can config correct the animation curves variables.
Unfortunately I don't have time to work on issues labeled as ambitious. For your project, maybe you could look into using ScriptableObjects to create your own preset system. It shouldn't be too much work to get a basic system working where you can click a button in the inspector to copy all variables from a script to the ScriptableObject to save them, and another button to copy all variables from the ScriptableObject to the actual script for loading.
The ScriptableObject could just be a class containing variables you want saved and loaded, no functions. Then you could have a variable on the script that contains a reference to the ScriptableObject and functions for loading and saving from it, called by button presses. You can look at the existing editor scripts for examples of inspector buttons.
If I was to commit this feature to the main branch, I would have to spend more time designing and testing it since many people would be using it. For one person's project you can often afford to use a less elegant and robust solution since it only has to work for your case, which is why maybe you would be able to figure out a basic solution. (I'm not sure how experienced you are with programming.)
ScriptableObjects could potentially work for serializing properties. Perhaps customizable classes could use an interface implementing methods for saving and loading presets. Some components might need multiple groups of customizable properties, such as a wheel having a group of properties for tire friction and another one for tire size or audio clips. Users might want to maintain the same friction preset for wheels on vehicles
My suggestion is to use standard unity feature for saving and loading presets for any component. The only problem here that you need redesign the composition of your components to put friction settings (for example) in separate class FrictionSettings. And make Wheel component work with that separate FrictionSettings component. When this done you can create folder Presets/FrictionSettings/ and put there different friction presets. For example Presets/FrictionSettings/FrictionSettingsDriftRaceWheel.preset
Using this approach Wheel component will not contain data anymore but only attached settings mixins components (such as FrictionSettings, WheelRotationSettings, WheelDamageSettings etc.). Wheel component will take all data from such components.
Another problem of this approach is that Presets is Editor only feature. So you can't apply presets at runtime in a final build of the game but you as can do it with ScriptableObjects.
Yes, my other asset uses ScriptableObjects for presets but I'm not willing to put in the time to refactor this one to work similarly. You are free to give it a shot if you would like.
no no, I am talking about saving preset feature of unity which works for any monobehaviour. The idea is that it could be more convinient than using ScriptableObjects. You will see all options right away in the inspector instead of switching to ScriptableObjects all the time
It is not easy to transfer certain properties between different instances of the same components or implement a vehicle customization system in a game. Being able to save and load presets for different components such as suspensions, transmissions, engines, wheels, and other parts would make it much easier to manage a project with many vehicles and allow them to be customized.
ScriptableObjects could potentially work for serializing properties. Perhaps customizable classes could use an interface implementing methods for saving and loading presets. Some components might need multiple groups of customizable properties, such as a wheel having a group of properties for tire friction and another one for tire size or audio clips. Users might want to maintain the same friction preset for wheels on vehicles, but load different presets for the sizes of the wheels and vice versa.