summaryrefslogtreecommitdiff
path: root/ch.sycoforge.Decal.Demo/Sinoid.cs
blob: 38ee2131bcc45ab7bee1b8262b5ae1825819e1b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using UnityEngine;

namespace ch.sycoforge.Decal.Demo;

public class Sinoid : MonoBehaviour
{
	public float AngularVelocity = 2f;

	public float SineFreq = 0.2f;

	public float Amplitude = 0.25f;

	private float accuTime;

	private Vector3 startPos;

	private void Start()
	{
		startPos = base.transform.position;
	}

	private void Update()
	{
		accuTime += Time.deltaTime;
		base.transform.position = startPos + Vector3.up * Amplitude * Mathf.Sin(accuTime * 2f * (float)Math.PI * SineFreq);
		base.transform.Rotate((Vector3.up + Vector3.forward) * AngularVelocity * Time.deltaTime);
	}
}