# How do I shoot water from gun

Get help using Construct 2

### » Wed Sep 28, 2016 4:54 pm

I have just been trying out construct 2 for a few days, but I am not facing this issue on learning how to shoot water out from a gun, where the water works similar to real life. Such as, holding the key will continue the water shooting, until when I let go of the key, the water will slowly stop shooting out.

B
7
S
1
Posts: 6
Reputation: 387

### » Wed Sep 28, 2016 5:29 pm

Here is an example to get you started. https://www.dropbox.com/s/0ru37dkgyhqvi ... .capx?dl=0

It will take some rather advanced artistic skill to make it actually look like water though.
B
61
S
30
G
134
Posts: 1,964
Reputation: 75,430

### » Fri Sep 30, 2016 5:18 am

Message: Hong can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
oosyrag wrote:Here is an example to get you started. https://www.dropbox.com/s/0ru37dkgyhqvi ... .capx?dl=0

It will take some rather advanced artistic skill to make it actually look like water though.

Omg thanks for the tutorial / example.
But i have a question on, what's this for or what does this variable means? " min(myvariable+50,2000) "
B
7
S
1
Posts: 6
Reputation: 387

### » Fri Sep 30, 2016 5:24 am

myvariable is the base speed of the water. As you hold down fire, the base speed at which it is created increases. The expression min() returns the smallest of the two values, in this case either myvariable+50, or 2000. This constrains the maximum of myvariable to 2000. If myvariable is already 2000, myvariable+50=2050. So min(2050,2000) will give you the smaller number, or 2000.

As a result, as long as the mouse is held down, myvariable will increase 50 every tick until 2000.
B
61
S
30
G
134
Posts: 1,964
Reputation: 75,430

### » Fri Sep 30, 2016 8:42 am

oosyrag wrote:myvariable is the base speed of the water. As you hold down fire, the base speed at which it is created increases. The expression min() returns the smallest of the two values, in this case either myvariable+50, or 2000. This constrains the maximum of myvariable to 2000. If myvariable is already 2000, myvariable+50=2050. So min(2050,2000) will give you the smaller number, or 2000.

As a result, as long as the mouse is held down, myvariable will increase 50 every tick until 2000.

Okay thanks for the explaining, but I'm still not sure why the myvariables is set as 0?

EDIT.
OKAY, i figured it out, meaning myvariable = 0 is the starting of a value before the increment of 50 ? am i right

But still, why do you need to add " Sprite bullet speed to myvariables+random() ? " when the speed increment value is 50... right?
B
7
S
1
Posts: 6
Reputation: 387

### » Fri Sep 30, 2016 4:10 pm

That just says the sprite can randomly start at a speed anywhere between myvariable and my variable+50. It is a small optimization, not required, to make it look better, as I am creating multiple instances per frame (due to the repeat). This way multiple sprites created the same frame don't all have the exact same speed, and there is some variation.

The speed starts at 0 to represent the pressure/spray from a water gun. This is necessary as you requested that the spray gradually decrease after letting go of the fire button.
B
61
S
30
G
134
Posts: 1,964
Reputation: 75,430