这个脚本是附加到平面螺旋桨和螺旋桨开始旋转平稳到最大的速度。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spin : MonoBehaviour
{
public float RotationSpeed = 1;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Rotate(0, 0, RotationSpeed, Space.Self);
if (RotationSpeed < 10)
{
RotationSpeed += 1f * Time.deltaTime;
}
}
}我添加了带有音频源组件的空游戏对象和控制音频源组件音调的脚本。

我想要做的是同步之间的螺距值变化和飞机螺旋桨的速度变化。
现在,当我运行游戏的时候,飞机螺旋桨开始旋转,我想用这个音高来发出像启动飞机引擎这样的声音,从慢到快。
发布于 2022-09-07 04:25:32
建议:
我相信你是在寻找:
public class AudioPitchManager : MonoBehaviour {
public int startingPitch = 4;
public int decreaseAmount = 5;
private AudioSource _audioSource;
void Start() {
_audioSource = GetComponent<AudioSource>();
_audioSource.pitch = startingPitch;
}
void Update() {
if( _audioSource.pitch > 0 ) {
_audioSource.pitch -= Time.deltaTime * startingPitch / decreaseAmount;
}
}
}AudioSource.Pitch被用来改变任何音频源的音高,只要你愿意.
希望能帮上忙..。快乐编码:)
https://stackoverflow.com/questions/73629906
复制相似问题