init
This commit is contained in:
commit
341a877b4a
2338 changed files with 1346408 additions and 0 deletions
21
Assets/NavMesh/Examples/Scripts/Oscillator.cs
Normal file
21
Assets/NavMesh/Examples/Scripts/Oscillator.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using UnityEngine;
|
||||
|
||||
// Makes a transform oscillate relative to its start position
|
||||
public class Oscillator : MonoBehaviour
|
||||
{
|
||||
public float m_Amplitude = 1.0f;
|
||||
public float m_Period = 1.0f;
|
||||
public Vector3 m_Direction = Vector3.up;
|
||||
Vector3 m_StartPosition;
|
||||
|
||||
void Start()
|
||||
{
|
||||
m_StartPosition = transform.position;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
var pos = m_StartPosition + m_Direction * m_Amplitude * Mathf.Sin(2.0f * Mathf.PI * Time.time / m_Period);
|
||||
transform.position = pos;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue