A button to shoot: How To ?

Hi there,
I’m working for mobile platforms (touch screen devices) and I use Unity 4.6 UI…
What I’m trying to do is simple: a UI button, when you press it, the in-game gun fires/shoot and once you stop pressing button (stop touch the screen) : the gun stops to fire !

unfortunately, I can’t do this properly alone, I spent a lot of time on it, trying to understand how to do. Spent time searching the web and this forum also !
the problem is that I can detect when the button start to be pressed but I don’t know when it’s released

my question is : what is the simple way to know when a UI Button is released, (no longer touched/pressed) (on mobile devices) ?
Thanks in advance !! :slight_smile:

hey, guys!
it’s okay now, I found out !

1 Like

Make your shooting a public function
Then, there where it sais onClick on the Button component select your object and your function

Hi…Im trying to do the exact game which is to shoot using a button…My problem is when i click the button, the log says it is shooting, but i don’t see any particles coming out… can you help?

hello ! so you’re using a particle system ? have you already used On Click ( ) ? take a look at unity Particle system API: Unity - Scripting API: ParticleSystem.Play

1 Like

Thank you sooo much…But i’m following another tutorial right now. If this doesn’t work, then i will check it out…Sorry, i give up easily…haha XD