# How do I make it when player is in certain range of AI, play a sound

**URL:** <https://forums.unrealengine.com/t/how-do-i-make-it-when-player-is-in-certain-range-of-ai-play-a-sound/489170>\
**Category:** AI\
**Tags:** range, unreal-engine, player, question\
**Created:** [September 24, 2021, 10:45pm UTC](https://forums.unrealengine.com/t/how-do-i-make-it-when-player-is-in-certain-range-of-ai-play-a-sound/489170 "2021-09-24T22:45:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JaydenTheYT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JaydenTheYT](https://forums.unrealengine.com/u/JaydenTheYT)\
**Post date:** [September 24, 2021, 10:45pm UTC](https://forums.unrealengine.com/t/how-do-i-make-it-when-player-is-in-certain-range-of-ai-play-a-sound/489170/1 "2021-09-24T22:45:19Z")

</div>

Can anyone help me on this please? I’m completely lost as I’m really new to UE4, I thought just make a variable of my AI or Player and when Sphere Collision is colliding play a sound, But no, the Player can only spawn with PlayerStart, or Current Camera Location, and the AI I can’t make a variable of BP\_Human because it doesn’t exist until you load the game.

Any help is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![13Mirra](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@13Mirra](https://forums.unrealengine.com/u/13Mirra)\
**Post date:** [September 25, 2021, 1:48pm UTC](https://forums.unrealengine.com/t/how-do-i-make-it-when-player-is-in-certain-range-of-ai-play-a-sound/489170/2 "2021-09-25T13:48:30Z")

</div>

Right click on your sound in the browser and create a cue, then add the cue to you ai BP.

---

<div class="post-metadata">

**Author:** ![JaydenTheYT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JaydenTheYT](https://forums.unrealengine.com/u/JaydenTheYT)\
**Post date:** [September 25, 2021, 3:10pm UTC](https://forums.unrealengine.com/t/how-do-i-make-it-when-player-is-in-certain-range-of-ai-play-a-sound/489170/3 "2021-09-25T15:10:17Z")

</div>

Sorry I’m a complete noob, what do you mean by “there is another actor node in Collison event”?

---

<div class="post-metadata">

**Author:** ![JaydenTheYT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JaydenTheYT](https://forums.unrealengine.com/u/JaydenTheYT)\
**Post date:** [September 25, 2021, 3:12pm UTC](https://forums.unrealengine.com/t/how-do-i-make-it-when-player-is-in-certain-range-of-ai-play-a-sound/489170/4 "2021-09-25T15:12:42Z")

</div>

But how do I make it start when the AI is close to me?

---

<div class="post-metadata">

**Author:** ![lucoiso](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lucoiso/32/820744_2.png) [@lucoiso](https://forums.unrealengine.com/u/lucoiso)\
**Post date:** [September 25, 2021, 3:14pm UTC](https://forums.unrealengine.com/t/how-do-i-make-it-when-player-is-in-certain-range-of-ai-play-a-sound/489170/5 "2021-09-25T15:14:17Z")

</div>

You can add a sound cue with a sound attenuation and adjust the attenuation parameters. There are a few ways to allow sound to be heard only if you are close to the sound source.If you want to add a player reference as a variable, you can do this when Begin Play is called, getting all AI character/AI actors from a class and with or without a tag or cast directly to the character getting his pawn by the controller. 🙂

---

<div class="post-metadata">

**Author:** ![JaydenTheYT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JaydenTheYT](https://forums.unrealengine.com/u/JaydenTheYT)\
**Post date:** [September 25, 2021, 4:15pm UTC](https://forums.unrealengine.com/t/how-do-i-make-it-when-player-is-in-certain-range-of-ai-play-a-sound/489170/6 "2021-09-25T16:15:10Z")

</div>

Thank you so much it works perfectly!
