28 lines
854 B
C#
28 lines
854 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class RainDirector : MonoBehaviour
|
|
{
|
|
public Vector3 planetCenter;
|
|
void Start()
|
|
{
|
|
ParticleSystem[] systems = GetComponentsInChildren<ParticleSystem>();
|
|
|
|
foreach (ParticleSystem ps in systems)
|
|
{
|
|
Vector3 dirToCenter = (planetCenter - transform.position).normalized;
|
|
|
|
var velocityOverLifetime = ps.velocityOverLifetime;
|
|
velocityOverLifetime.enabled = true;
|
|
velocityOverLifetime.space = ParticleSystemSimulationSpace.World;
|
|
velocityOverLifetime.x = dirToCenter.x * 20f;
|
|
velocityOverLifetime.y = dirToCenter.y * 20f;
|
|
velocityOverLifetime.z = dirToCenter.z * 20f;
|
|
|
|
var main = ps.main;
|
|
main.gravityModifier = 0f;
|
|
}
|
|
}
|
|
}
|