x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Play a sound once on event tick used as a Linetrace by Channel

Hi guys! I have the next question.

I'm using a tick event for a LineTraceByChannel emulating the mouseover event with a ray. Everytime that the ray hit on an specific object a sound should be triggered once.

When I put the node "Spawn sound attached" to play the sound it plays but in a loop. So, i thought about to use "DoOnce" node.

If I use the "DoOnce" node the sound plays once but then not anymore and I need that this sound plays everytime that the ray hit on the object.

I don't know how to setup the "reset" property of DoOnce because if i use a Branch asking if the sound is playing it doesn't works.

Any clue?? Thanks!!!

Hector

Product Version: UE 4.15
Tags:
more ▼

asked Aug 12 '17 at 04:17 PM in Blueprint Scripting

avatar image

g0mo
8 8 11 13

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Hi guys! thank you so much for the help. Finaly i solved it doing another Raytrace that evaluate the name of the object that is hit and then if the name is equal to the object name that has to play a sound, i Spawn the sound with DoOnce. If not, it reset and works good.

Now i have another problem. I need to do this with several objects so I was thinking to use an Array, but i don't know how to do it. May you help me with that please?

Thank you!

alt text

hitornot.jpg (462.7 kB)
more ▼

answered Aug 14 '17 at 08:49 PM

avatar image

g0mo
8 8 11 13

avatar image g0mo Aug 14 '17 at 09:27 PM

I couldn't make an array, so i solved it with a chain of "or" one after another. I close the question. Thank you again!!

avatar image BenVlodgi Aug 15 '17 at 04:44 PM

You should mark the answer that solved your question upvote the ones that helped, and add your solution as an edit to your question.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Once your trace hits a object, store that object in a variable class.
Before playing your sound, check if your current target is different from the previous one (the one in your variable class). This way, your sound will be played only when you're hitting a new target.

more ▼

answered Aug 13 '17 at 04:12 AM

avatar image

Syalen
126 5 9 12

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You should have your NotePlayer as a separate actor in the world. This should have a bool indicating whether or not it is playing. Set the boolean to true when it is told to play, and set it to false after the minimum reset time.

If the bool is true when it is told to play, use a branch to not play the note.

Then when you mouse over the NotePlayer, call the play note function you'll create. Then it can only be called once until the minimum reset time has elapsed.

more ▼

answered Aug 12 '17 at 07:33 PM

avatar image

BenVlodgi
2.2k 39 17 52

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question