Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Ошибка юнити 3д

negr vasya Ученик (23), на голосовании 11 месяцев назад
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SingleShotGun : Gun
{
[SerializeField] Camera cam;
[SerializeField] AudioClip shootingSound; // добавляем поле для аудиофайла

private AudioSource audioSource; // создаем переменную для AudioSource

void Start()
{
audioSource = GetComponent<AudioSource>(); // получаем ссылку на AudioSource
}

public override void Use()
{
Shoot();
}

void Shoot()
{
Ray ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f));
ray.origin = cam.transform.position;
if(Physics.Raycast(ray, out RaycastHit hit))
{
hit.collider.gameObject.GetComponent<IDamageable>()?.TakeDamage(((GunInfo)itemInfo).damage);
}

// проигрываем звук выстрела
if (shootingSound != null && audioSource != null)
{
audioSource.PlayOneShot(shootingSound);
}
}
}


не работает произведение звука при стрельбе
There are 2 audio listeners in the scene. Please ensure there is always exactly one audio listener in the scene.
Голосование за лучший ответ
Failed to load resource netERR Просветленный (26013) 1 год назад
Убери одного audio listener
negr vasyaУченик (23) 1 год назад
а где он?
negr vasyaУченик (23) 1 год назад
я вас не понял, что нужно убрать?
Failed to load resource netERRПросветленный (26013) 1 год назад
Так в ошибке сказано. Это код ии?
Похожие вопросы