最近、Unityになってしまったので、私は学校からの譲渡を受けて、iveはミラーエッジの感じのゲームを作ることにしましたが、より基本的なボールの周りの転がりと。問題は、ピックアップ・シーブが置くように試みたが、音を出さないことである。私はそれを修正する方法を知っていないとアイブは解決策を探してみましたが、それはちょうど仕事を失う。誰でも助けてくれますか?あなたもどこでもあなたのスクリプトで再生機能を呼び出していないされているので、サウンドが再生されませんC#/ Unityピックアップにサウンドを追加すると動作しない
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Player_Controller : MonoBehaviour {
public float speed;
public Text countText;
private Rigidbody rb;
private int count;
void Start()
{
rb = GetComponent<Rigidbody>();
count = 0;
SetCountText();
}
void FixedUpdate()
{
float moveHorizonal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizonal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("pickup"))
{
AudioSource audio = GetComponent<AudioSource>();
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
}
void SetCountText()
{
countText.text = "Count: " + count.ToString();
}
}
'audio'オブジェクトに' Play() 'の呼び出しはありません。 –