jueves, 20 de abril de 2023

ejemplo de sript C# unity de sonido por colision y tag;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SUENAPORTACELBEBEALPASAR : MonoBehaviour
{



    public AudioSource tickSource;


    void Start()
    {

        tickSource = GetComponent<AudioSource>();

    }

    void Update()
    {
    }

    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("caca"))
        {


            tickSource.Play();

            //Destroy (gameObject, 0.2f);


        }
    }

}