- Home /
Selecting a Car for a scene!
Hello, I've made a menu wherein user is asked to select a car and the scene or the race starts with that car, what I've done now is to create different scenes and on clicking that car, I'm opening that scene. But i feel it makes the game size more, and I believe there's a way to place all the cars in a single scene and only enable the one which the user selects, this can be done by scripting I suppose just like switching the camera. Any idea anybody?
Answer by Henrik Poulsen · Feb 24, 2013 at 10:58 AM
You can prevent GameObjects from being destroyed when you change a scene. So for example if you have spawned all the cars in the car selection scene, then you let the player select which car they want to use.
if(selectedCar != null)
{
DontDestroyOnLoad(selectedCar);
// Here you can load the next scene or whatever it is you want to do.
}
That way the car the player selected wont get destroyed and it will be available even after you have changed your scene. So then you just get that car via a script and use it. So then you can re-use the same scene no matter what car the player chooses and you don't need to have a car present in the scene, since the player brings it along from the car selection screen.
Even though it doesnt give me what I require, it did guide me in a way. Thank you
Your answer
![](https://koobas.hobune.stream/wayback/20220613093306im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Car NOS Boost 3 Answers
How to change scenes by touching objects? 2 Answers
How can i rotate my car steering wheel in accordance to the wheels? 1 Answer
Camera Switching or Scene Changes? 3 Answers