Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

31 行
765 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(AudioSource))]
public class BoatAudioCollision : MonoBehaviour
{
public AudioClip[] audioClips;
public float variability = .5f;
private AudioSource audioSource;
private void Start()
{
audioSource = gameObject.GetComponent<AudioSource>();
}
void OnCollisionEnter(Collision col)
{
if(col.gameObject.layer == gameObject.layer)
{
int c = Random.Range(0, audioClips.Length-1);
AudioClip clip = audioClips[c];
audioSource.clip = clip;
audioSource.pitch = 1 + Random.Range(-variability, variability);
audioSource.Play();
}
}
}