How do I shoot water from gun

0 favourites
  • 6 posts
From the Asset Store
Shoot balls to destroy as many blocks as possible, at each stage the game will become more difficult.
  • 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.

    Sorry, bad english...

  • 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.

  • Here is an example to get you started. 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) "

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)