How to play sounds when overlapping foliage

I’m trying to figure out how to play specific sound effects when I overlap grass, weeds and bushes in my game.

I’m able to get overlap events for the InstancedFoliageActor, but that’s for the entire collection of foliage in the world, so it doesn’t seem to allow me to play unique sounds for different types of foliage.

Is there a way to do this in the engine out of the box? I’m using 4.8 preview 3.

Thanks!

Hey JigglyToes,

Have you considered using trigger boxes in the foliage area? Here is a screenshot of a trigger box blueprint which when it’s stepped on, the character is lit up in flames and there is a burning noise, once 5 seconds has passed, the flames disappear as long as you’re off of the trigger.

So, if you have different types of foliage, you can set up trigger boxes around your map where that foliage is and it’ll be connected to the different sounds you’re wanting for each type of plant.

Let me know if you have any further questions, I’ll be more than happy to investigate this further for you. :slight_smile:

Hi Samantha,

That could work in small levels, but we’ll be placing thousands and thousands of them in our world, which makes it very impractical to manually and accurately place triggers on each one of them, especially if we iterate on the layout of our levels.

It would be much better if I could somehow tag each type of foliage with a type, then have a piece of code or a blueprint play a sound based on the type.

Hey JigglyToes,

If you have a specific type of grass actor that you’re using and you’re not using that anywhere else, you could simply set up an object overlap event with a custom collision (or object) channel (foliage). Once you set that up, every time the player overlaps an object with the foliage collision it’ll play a sound. Make sure you set it up within the player character.

If you have any further questions, please let us know.
Enjoy your weekend! :slight_smile:

except that blueprints cannot be used with the foliage tool, only static meshes, which you can’t hook up events too. and my character does not seem to recognize events through overlapping with foliage objects

Hey HuntaKiller,

The foliage tool doesn’t work with blueprints like static meshes do. If you’re having trouble with getting your foliage and blueprints to match up, please submit a new post to AnswerHub and describe exactly what’s happening. Please do not forget to include a sample project or uploaded photos of your blueprints so we can try to replicate and resolve the issue.

Thank you! :slight_smile:

I know the foliage/dynamic-foliage tool only works. I’m referring to what you suggested, “you could simply set up an object overlap event with a custom collision (or object) channel (foliage)”, how do I do that if you can’t add any functionality to foliage. Currently a trace CAN detect foliage instances but how do you know to start that trace if the overlap event doesn’t fire. You would have to do a trace around the player on tick, which is an expensive replacement for an overlap event.

Hey I know it’s too late but I was searching for this exact answer so I’m going to necro this thread.

Samantha Sutton to my knowledge posted a good answer but one that didn’t work for this situation. HuntaKiller you need to go to your Project Settings → Collision and create a new trace channel for your bushes/foliage. Default should be ignore.

Now, in your foliage collision settings you can set it to overlap with that trace channel. You can then create an event on event tick or timer that linetraces from the player down to the ground and checks for that channel. If it returns true, then play a rustle sound. I also added a cooldown so that my player wouldn’t be spammed with that noise.

I hope this helps everyone because I spent a few hours trying to figure this out…

I’m posting this as a comment and a response so that it’s more visible. This solution worked for me and will work for you too.

Hey I know it’s too late but I was searching for this exact answer so I’m going to necro this thread.

Samantha Sutton to my knowledge posted a good answer but one that didn’t work for this situation. HuntaKiller you need to go to your Project Settings → Collision and create a new trace channel for your bushes/foliage. Default should be ignore.

Now, in your foliage collision settings you can set it to overlap with that trace channel. You can then create an event on event tick or timer that linetraces from the player down to the ground and checks for that channel. If it returns true, then play a rustle sound. I also added a cooldown so that my player wouldn’t be spammed with that noise.

I hope this helps everyone because I spent a few hours trying to figure this out…