|
Post by Lykos on Apr 2, 2015 9:51:27 GMT
Hello, I'm trying desperately to solve a problem that shouldn't even exist. Here's my code: public int i = 1; //I use this variable later
void Update() { if (i == 1) {
if (Input.GetTouch (0).phase == TouchPhase.Began) { Touch touchPos = Input.GetTouch (0); Vector3 createPos = Camera.main.ScreenToWorldPoint (new Vector3 (touchPos.position.x, touchPos.position.y, 10));
//Instantiate(nome, createPos, Quaternion.identity); PoolBoss.Spawn(nome, createPos, Quaternion.identity, nome); } } } As you can see i have in the code also a //Instantiate(nome, createPos, Quaternion.identity); that i used to check if anything was wrong with the touch position or similar.. This code should spawn on touch position a prefab "nome" from the pool. The same code used for mouse clicks works perfectly, but i can't figure out why it doesn't work for touch. Any help would be appreciated  Thanks
|
|
|
Post by DarkTonic Dev on Apr 2, 2015 15:19:50 GMT
Try this:
PoolBoss.SpawnInPool(nome, createPos, Quaternion.identity);
That last parameter in Spawn is supposed to be the parent of the spawn, so the same would be to pass there instead of "nome" again.
|
|
|
Post by Lykos on Apr 2, 2015 15:32:00 GMT
Hey, thanks for the answer. I tried your solution before and here's the error Assets/InstantPoolClick.cs(46,42): error CS1501: No overload for method `Spawn' takes `3' arguments This error appear only when i try to use 3 parameters instead of 4. So i tried to fake it inserting "nome" again 
|
|
|
Post by Lykos on Apr 2, 2015 16:04:50 GMT
Ok, I apparently "solved" the problem. What i mean: now it does work, but i had to create a public Transform variable named "fake", leave it unassigned and things seems to work. (But I know its not the correct/optimized solution. Another problem I am facing with now it's the lag. I use the pooling to avoid lags on mobile devices and it should be like this... but after some spawns it keep lagging. Any ideas? Thanks in advance 
|
|
|
Post by DarkTonic Dev on Apr 2, 2015 19:29:17 GMT
My posted code above says to use "SpawnInPool", so you don't need the last parameter. Look at it again.
Or you can pass a null for the last parameter with the Spawn method:
PoolBoss.Spawn(nome, createPos, Quaternion.identity, null);
|
|
|
Post by Lykos on Apr 2, 2015 22:10:05 GMT
Sorry, my mistake, I didn't read it correctly! Thanks for your help  !!
|
|
|
Post by DarkTonic Dev on Apr 2, 2015 23:52:21 GMT
No problem!
|
|