Right now, I’m generating static meshes along a spline via blueprints. The static meshes generated by the blueprint don’t appear in ‘World Outliner’ instead only the spline does.
From what I’ve read, I want to create an audio component that is attached to each of the static meshes and associate that with a trigger volume. When the camera (and only the camera) overlaps the trigger volume, the audio component for that trigger volume will play.
My question is: How do I attach an audio component / trigger volume to a static mesh that is being generated by blueprints (via Add Static Mesh Component)?
I don’t think you can add it to the add static mesh component directly, however it could it live within the spline?
How would I do this? Is ‘Add Sphere Collision’ what I’m looking for?
depends on the shape of your spline I guess, any collision volume can be used to trigger overlap and play the audio.
If your static mesh already has collisions on it then you don’t need a collision sphere or other collision object (unless you want the collision to be greater than the size of your mesh.) Assuming you are putting the spline on the map during editing rather than at run time, add trigger volumes where you want them along the spline, then have it trigger an event on the mesh, where the event is to play your audio. If you have multiple triggers and only want it to trigger once, you can do a check to see if the audio is currently playing and if so, ignore the trigger.
If you want only your camera to overlap the trigger then I suggest creating a custom Collision Object, name it something appropriate like ‘Camera’. Go to your camera(s) and set it’s Object type (in the Collision settings) to the type Camera. Then, on your trigger volumes, set it to only overlap ‘Camera’ objects and ignore the rest. Ensure that ‘Generates Overlap Events’ is enabled on your mesh/camera.
Hope this help! If it does, please do me a favor and accept the answer by clicking the check mark next to the answer. You’ll know you got it right when the answer (and it’s comments) turn green! Note that if a comment is made after you accept an answer it automatically unaccepts the answer! Thanks! Let me know if you have any other questions.
Jesse
I’ve created collision spheres for each of the static meshes. These static meshes are spawned via Blueprints. How do I make sure that the ‘Generates Overlap Events’ option is selected for these spawned static meshes (with associated collisions)?
Also, how do I check for collisions for each of these spawned static meshes?
Using a simple static mesh and trigger volume won’t really work on it’s own. Yes, the collisions will happen but you can’t do anything with them as they are. You need a way to add functionality to it, i.e. make blueprints that can trigger events.
I suggest making you static mesh(s) into blueprints. Depending on how your game is setup, you should try to do a good parent/child hierarchy with them instead of individual BP’s for every mesh. But again, this all depends on your game. Either case, in the blueprint of your static mesh you can trigger events when overlapping using the “Begin Overlap” event. Not much detail is given regarding your project so it’s hard to give you specifics.
You can also put a reference to your trigger volume(s) into the level blueprint and use the Begin Overlap in there as well; however, the output from this (as with most begin overlap events) is of type Actor Reference which means anything overlapping it will need to be a blueprint of type Actor (or a child of this type) so there’s really no way to get around making your meshes into Blueprints.
Using the method of putting the overlap code into the Level BP using the Trigger Volume is probably a better way to go than adding a collision sphere to the meshes because I assume you are only wanting the event to occur when the actual mesh collides with the trigger? Adding a collision sphere to the mesh/blueprint of the mesh and using it’s overlap event means that the mesh doesn’t need to actually pass through the trigger (only it’s collision sphere) to trip the Overlap Event whereas using the overlap of the Trigger Volume will only trip when the mesh blueprint passes through.
Hope I didn’t confuse you! Let me know if you have any other questions.
Jesse