- Home /
How to pull two objects at the same time?
i am trying to develo[e a game like "BRAIN RUSH". In origional game, as time passes playing, difficulty increases, where the falling objects' speed is increasing and also there you can see as in imagw no.1, more than one object falling on screen. But in my case, i can make only one object falling on screen at one time as shown in image 2. How to make them two.
Below is my code.
using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Linq;
public class Poolingscript3 : MonoBehaviour { public Texture[] txtr; public List list1; List list2; public float dragg; float speed = 3.0f; void Start () { InvokeRepeating ("faller", 1.0f, 1.0f); }
GameObject temp;
GameObject[] temp2;
void faller()
{
int RandomNo = Random.Range(0,2);
temp = list1.FirstOrDefault<GameObject>();
temp.renderer.material.mainTexture = txtr[RandomNo];
temp.transform.position = transform.position;
list1.Remove(temp);
temp.SetActive(True);
speed += Time.Deltatime * 5.0f;
}
GameObject gu;
void Update()
{
temp.gameObject.transform.Translate (Vector3.down * Time.deltaTime * speed);
}
public void addtolist(GameObject g) { g.SetActive (false); list1.Add (g.gameObject); }
}