(スクリプト)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyShotShell_Sound : MonoBehaviour
{
public GameObject shellPrefab;
public AudioClip sound;
private int count;
// 効果音
private AudioSource audioX;
private void Start()
{
// 効果音
audioX = GetComponent<AudioSource>();
}
private void FixedUpdate()
{
count += 1;
if (count % 20 == 0)
{
GameObject shell = Instantiate(shellPrefab, transform.position, Quaternion.identity);
Rigidbody shellRb = shell.GetComponent();
shellRb.AddForce(transform.forward * 1000);
Destroy(shell, 5.0f);
// 効果音の発生
audioX.PlayOneShot(sound);
// 音量調整
audioX.volume = 0.3f;
}
}
}