mirror of
https://github.com/celisej567/metaballs.git
synced 2026-09-21 20:15:02 +03:00
Initial code commit
This commit is contained in:
20
Assets/Scripts/MetaLight.cs
Normal file
20
Assets/Scripts/MetaLight.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
[RequireComponent(typeof(Light))]
|
||||
public class MetaLight : MonoBehaviour {
|
||||
public Ball linkedMetaball;
|
||||
public float intensity;
|
||||
|
||||
private float phaseShift;
|
||||
private Light lightComponent;
|
||||
|
||||
void Start () {
|
||||
this.phaseShift = Random.Range(0, Mathf.PI);
|
||||
this.lightComponent = this.GetComponent<Light>();
|
||||
}
|
||||
|
||||
void Update () {
|
||||
this.lightComponent.intensity = this.intensity * (this.linkedMetaball.transform.localPosition.magnitude + (1 + Mathf.Sin(this.phaseShift + Time.time/2)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user