initial commit
This commit is contained in:
27
Assets/Scripts/RainDirector.cs
Normal file
27
Assets/Scripts/RainDirector.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user