Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Fontan : MonoBehaviour
- {
- public GameObject Woda;
- public float power, cubesCount = 100, height = 1, xCot = 1, zCot = 1, speed = 0.2f;
- // Start is called before the first frame update
- void Start()
- {
- StartCoroutine("Spawn");
- }
- IEnumerator Spawn()
- {
- for (int i = 0; i < cubesCount; i++ )
- {
- Vector3 direction = new Vector3(Random.Range(-1f, 1f) * xCot, height, Random.Range(-1f, 1f) * zCot);
- Instantiate(Woda, transform.position, Quaternion.identity).GetComponent<Rigidbody>().AddForce(direction * power, ForceMode.Force);
- yield return new WaitForSeconds(speed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement