27 lines
753 B
C#
27 lines
753 B
C#
using UnityEngine;
|
|
|
|
public class WindEffect : MonoBehaviour
|
|
{
|
|
private WindZone windZone;
|
|
|
|
private Vector3 startRotation;
|
|
|
|
private Vector3 startPosition;
|
|
|
|
private float StartDelay;
|
|
|
|
private void Start()
|
|
{
|
|
windZone = Object.FindObjectOfType<WindZone>();
|
|
startRotation = base.transform.localEulerAngles;
|
|
startPosition = base.transform.position;
|
|
StartDelay = Random.Range(0f, 1f);
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
base.transform.localEulerAngles = startRotation + Vector3.left * Mathf.PingPong(Time.time * windZone.windTurbulence * 0.2f * StartDelay, windZone.windMain * 5f);
|
|
base.transform.position = startPosition + Vector3.left * Mathf.PingPong(Time.time * windZone.windTurbulence * 0.1f * StartDelay, windZone.windMain * 0.1f);
|
|
}
|
|
}
|