x


How to spawn prefab from a single cache when using multiple caches?

Using AngryBotsAssetsScriptsManagersSpawner.js from Unity's AngryBots demo to store multiple prefabs into different caches to avoid slowdowns. Limiting this example to two caches for simplicity.

cache01 holds prefab of player fire objects. (Simplebullet.js is close enough, for example.) cache02 contains prefab of target objects. (Uses OnEnable() for random placement and vectoring.)

Start(){ // called once in the lifetime of the behaviour
    InvokeRepeating("Spawn", timeToStartSpawning, timeDelayBetweenSpawns);
}

...is tempting, but results in "Trying to Invoke method: Spawner.Spawn couldn't be called.". And would spawn from both caches if it did work if I following the logic properly.

Spawning the player's fire is meant to be on demand. Spawning/Despawning from the target cache is to be continuous until levelEnd conditions are reached. (Timer in this example.)

How do I spawn from a single cache, basically within a container cache, without causing all to activate? Or am I going to have to brute force my way with SpawnTarget() and SpawnFire()? (Which seems like a bit of overhead as the number of caches increases.)

more ▼

asked Feb 28 '12 at 01:17 AM

MapMonkey gravatar image

MapMonkey
31 1 1

I have the same reason, Invoke works in all other places except one place, i tried changeing everything, but no use still the same happens. Any one has solution?!

Mar 20 '12 at 02:10 PM flamy
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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:

x5086
x1259
x440
x75
x50

asked: Feb 28 '12 at 01:17 AM

Seen: 437 times

Last Updated: Mar 20 '12 at 02:10 PM