Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Serialization;
- namespace Ninsar.Content.Tonnelle.Scripts
- {
- public class AudioSyncPosition : AudioSyncer
- {
- private IEnumerator MoveToScale(Vector3 _target)
- {
- Vector3 _curr = transform.position;
- Debug.Log(_curr);
- Vector3 _initial = _curr;
- float _timer = 0;
- while (_curr != _target)
- {
- _curr = Vector3.Lerp(_initial, _target, _timer / timeToBeat);
- _timer += Time.deltaTime;
- transform.position = _curr;
- yield return null;
- }
- m_isBeat = false;
- }
- public override void OnUpdate()
- {
- base.OnUpdate();
- if (m_isBeat) return;
- transform.position = Vector3.Lerp(transform.position, restPosition, restSmoothTime * Time.deltaTime);
- }
- public override void OnBeat()
- {
- base.OnBeat();
- StopCoroutine("MoveToScale");
- StartCoroutine("MoveToScale", beatPosition);
- }
- void Start()
- {
- restPosition = transform.position;
- beatPosition = restPosition + new Vector3(0, 0f,0.1f);
- }
- public Vector3 beatPosition;
- public Vector3 restPosition;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement