28 lines
565 B
C#
28 lines
565 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ArrowsFloat : MonoBehaviour
|
|
{
|
|
Vector3 trans1;//记录原位置
|
|
Vector2 trans2;//简谐运动变化的位置,计算得出
|
|
|
|
[Header("振幅")]
|
|
public float zhenFu = 5f;
|
|
[Header("频率")]
|
|
public float HZ = 1f;
|
|
|
|
private void Awake()
|
|
{
|
|
trans1 = transform.position;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
trans2 = trans1;
|
|
trans2.y = Mathf.Sin(Time.fixedTime * Mathf.PI * HZ) * zhenFu + trans1.y;
|
|
|
|
transform.position = trans2;
|
|
}
|
|
}
|