x


How to not load an object with playerpref

I have a simple game where player search for items and pick them up. How would I set up a playerpref script, so that when the game is relaunched the player would not have to find them again? I understand playerpref's a bit but I confused as to how I would save that an object was found and to not load it on re-launch. I'm not asking for a script to be written , just pointed in the right direction. Thanks in advance

more ▼

asked Apr 11 '12 at 09:28 AM

kangta gravatar image

kangta
18 5 9 12

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

1 answer: sort newest

There are many ways you could do this!

One I can think of:

var playerObjects : int[];

enum ObjectsYouCanPickUp
{
     CoolObject,
     UselessObject,
     LuckyCoin
}

You then fill the playerObjects array as the player picks up stuff, not forgetting parseInt : playerObjects[freeIndex] = parseInt(ObjectsYouCanPickUp.LuckyCoin);

That way, you can save playerObjects in PlayerPrefsX(ArrayPrefs) as an int[].

more ▼

answered Apr 11 '12 at 09:48 AM

gregzo gravatar image

gregzo
1.6k 31 42 51

How would that set the object to not be loaded when the game is re-launched?

Apr 13 '12 at 03:29 AM kangta
(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:

x301

asked: Apr 11 '12 at 09:28 AM

Seen: 381 times

Last Updated: Apr 13 '12 at 03:29 AM