x


DontDestroyOnLoad problem

I'm making a board game. In my game when a player wants to throw dice s/he will be led to another scene and then after some seconds it will be led back to the board game. But this caused that the scene be built from the beginning so the players loose their last locations. I tried to use "DontDestroyOnLoad()" but it makes a copy of each character , each time the players comes back to the scene. I mean after 10 times of throwing dice I will have 10 copies of each character. How can I solve this problem? Thanks for your helps

more ▼

asked Dec 31 '11 at 12:19 PM

sanamdehghan gravatar image

sanamdehghan
46 14 21 23

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

You can build the scene without any player characters and have a script that checks if the necessary objects are in the scene, and if not spawn them.

You can also have the dice throw sequence take place in the same scene, with a different camera (that renders on a different layer using Camera.depth and switch between cameras (enable/disable)

more ▼

answered Dec 31 '11 at 01:57 PM

asafsitner gravatar image

asafsitner
2.4k 2 8 19

Thanks for your help. I tried the second approach you recommended. It solves my problem but causes many other problems I couldn't solve. So I decided to test the first approach. But I don't know how exactly do that. Would you help me about that? thanks in advanced

Jan 01 '12 at 01:04 PM sanamdehghan

I think you could make a separate scene with all the "don't destroy" object and avoid having "don't destroy" object in runtime loaded scenes.

Jan 01 '12 at 01:19 PM tomekkie2
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x82

asked: Dec 31 '11 at 12:19 PM

Seen: 562 times

Last Updated: Jan 01 '12 at 01:19 PM