Gameplay Ingredients是一组用于 Unity 游戏的运行时和编辑器工具:一组脚本的集合,可在制作游戏和原型时简化简单的任务。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

29 行
919 B

using UnityEngine;
namespace GameplayIngredients.Rigs
{
[AddComponentMenu(ComponentMenu.rigsPath + "Floating Rig")]
public class FloatingRig : Rig
{
public override int defaultPriority => 0;
public override UpdateMode defaultUpdateMode => UpdateMode.Update;
public Vector3 Frequency = new Vector3(4, 5, 6);
public Vector3 Amplitude = new Vector3(0.0f, 0.2f, 0.0f);
Vector3 m_InitialPosition;
private void Awake()
{
m_InitialPosition = transform.position;
}
public override void UpdateRig(float deltaTime)
{
float t = (updateMode == UpdateMode.FixedUpdate)? Time.fixedTime : Time.time;
transform.position = m_InitialPosition + new Vector3(Mathf.Sin(t * Frequency.x) * Amplitude.x, Mathf.Sin(t * Frequency.y) * Amplitude.y, Mathf.Sin(t * Frequency.z) * Amplitude.z);
}
}
}