Question by
KGB_OFFICER_01 · Jun 23, 2018 at 01:22 AM ·
c#ontriggerenter
Play Sound on Trigger... At a distance?
I have the following script :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DoorAutoOpen : MonoBehaviour {
public AudioClip DoorSqueak;
public GameObject Door;
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "Player")
{
AudioSource.PlayClipAtPoint(DoorSqueak, transform.position);
Door.GetComponent<Animation>().Play();
}
}
}
The trigger is at the bottom of a staircase, how would i have the audio playing on the doors location(top of stairs) instead of the players position?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612165317im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Lose Health when GameObject enters collider? (OnTriggerEnter) 2 Answers
NullReferenceException: Object reference not set to an instance of an object 0 Answers
How to disable OnTriggerEnter on one script? 1 Answer
How to deadtivate a gameobjects from the scene, if player has a character controller 0 Answers
Bullets doesnt do any damage 3 Answers