I am creating a block breaker type game and I want the launch speed of the ball to be different in different levels. How would I use the same script but only change a portion of it in a different level?
Put it on a new GameObject in the new scene. Configure it differently via the inspector.
I’m a big fan of keeping game config in a JSON file, and keeping it on a server.
Allowing you to tweak the config without having to update any code, and loading it from the server when the game loads.
If not using a server, you can read a JSON file from StreamingAssets.
Putting config in JSON allows you to easily tweak a lot of values at once.
For instance, if you have 20 levels, and want to slightly increase the ball speed for each level, its easier to quickly edit a JSON file, than open every scene and change each GameObject individually.
An even better way to do it, is create a config generator class, that uses base values and offset values for the ball speed on all your levels to instantly generate your JSON config.
It really depends how often you will be tweaking values and fine tuning your game.
But @Kiwasi 's solution is nice and simple if you don’t want to get too heavy into any details and only have a few levels ![]()
How do I do that, It isn’t a public variable that I can edit with the inspector.
Expose it to the editor with [SerialiseField]