Is there a way of activating the object which is in proximity to the player ?
I need to come up with a BP that makes it so that when the player can press E to activate and deactivate individual objects which have separate sounds.
Example : Triangle shape plays fire sound when E key is pressed in proximity, when E key is pressed again it stops ................playing. Circle shape plays water sound when E is pressed in proximity , it also stops when E is pressed again. Circle and triangle can also both be pressed in successive order when in proximity and will each .................individually play their sounds, they can also both be stopped whenever they are clicked on again.
Optional: I need to know how to make Objects/Shapes change colour on key press.
asked Nov 04 '14 at 12:27 AM in Blueprint Scripting
Make the Audio you want to play as an Audio Component in the BP. Put a Sphere component on the Blueprint and set it to the radius you want the object to be interactive at. Add events for the sphere component: OnComponentOverlapBegin and OnComponentOverlapEnd. Plug these into a Gate Node. Begin into Open and End into Close. Take the "other actor" option from the overlap nodes, click and drag them out and Cast to [yourCharacterBpNameHere]. This makes it so that when the player overlaps the sphere component, something can happen.
Next, you make a Blueprint Interface Node and plug up both the Character and ShapeBP together. There are many tutorials for this with video instructions for passing messages from one BP to another. You will take the event and plug it into the Gate Node, then into a branch with a "is Playing" bool attached to keep track if the audio component is playing or not. Reference the Audio Component and make a Play and Stop node from it. Plug the Play node to the False section of the Branch (and add a Set "isPlaying" to True Node); Next add the Stop node to the True section of the branch(and add a Set "isPlaying" to False Node).
Now when the event from the player comes in while he is overlapping the sphere component and the bool 'IsPlaying' is False, it will Play the audio and set isPlaying to true, and vice versa.
answered Nov 04 '14 at 06:14 AM
Yes it did, i did not end up implementing it in my game in the end though. Thanks for your help, I appreciate it.
answered Feb 01 '15 at 10:35 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here