0 votes

Hiyo!
I'm using a TextureButton, and want a click noise to play whenever I hover my mouse over the top of it. How would I do it without it spamming the sound? (I turned off looping by the way)

Thanks,
Thayus.

Godot version 3.4.2
in Engine by (12 points)

Dİd you use Signal ?
and show the code. just that part

1 Answer

+1 vote

easiest way is to have a bool variable that you set to true on mouse enter, and false on mouse exit...

var playedSound = false

func myMouseEnter(event):
  if not playedSound:
     mySound.play()
     playedSound = true

func myMouseExit(event):
   playedSound = false
by (1,342 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.