Advertisement
Ychenik

Fountain

Apr 8th, 2020
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Fontan : MonoBehaviour
  6. {
  7.     public GameObject Woda;
  8.     public float power, cubesCount = 100, height = 1, xCot = 1, zCot = 1, speed = 0.2f;
  9.  
  10.     // Start is called before the first frame update
  11.     void Start()
  12.     {
  13.         StartCoroutine("Spawn");
  14.     }
  15.  
  16.     IEnumerator Spawn()
  17.     {
  18.         for (int i = 0; i < cubesCount; i++ )
  19.         {
  20.             Vector3 direction = new Vector3(Random.Range(-1f, 1f) * xCot, height, Random.Range(-1f, 1f) * zCot);
  21.             Instantiate(Woda, transform.position, Quaternion.identity).GetComponent<Rigidbody>().AddForce(direction * power, ForceMode.Force);
  22.  
  23.             yield return new WaitForSeconds(speed);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement