Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SpawnObjects : MonoBehaviour
- {
- public GameObject[] RandomObjects;
- public void spawnSomeObjects()
- {
- GameObject Gobj = Instantiate(RandomObjects[0]) as GameObject;
- Gobj.transform.position = new Vector3(0f, 50f, 5f);
- }
- }
- public class BucketMovement : MonoBehaviour {
- SpawnObjects SpawnObj;
- public float TimeSpawn = 2.0f;
- public float AssignTimeSpawn = 2.0f;
- void Start()
- {
- SpawnObj = GameObject.FindObjectOfType<SpawnObjects>();
- }
- void Update ()
- {
- TimeSpawn -= Time.deltaTime;
- if (TimeSpawn < 0)
- {
- TimeSpawn = AssignTimeSpawn;
- SpawnObj.spawnSomeObjects();
- }
- }
- public class CollisionToBucket : MonoBehaviour {
- void OnCollisionEnter2D(Collision2D other)
- {
- if(other.gameObject.tag == "Object")
- {
- //tried with isTrigger, no luck at all, objects would collide with
- //them selves and then fall out of the world ignoring the bucket
- //tried also with collider.enabled = false; but unity tells me that I can't
- //access that property
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement