frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

How to make a character shoot?/How to make a button correspond to an animation?

So I've been working on this: https://flowlab.io/game/play/928705; I've been trying to make it as some sort of Smash Bros-ish game, and I need some help. I've been trying to make my characters shoot. Does anyone know how to program this? Also, does anyone know how to connect an animation to this sort of thing?

Comments

  • edited June 9
    We have a very helpful help section on the website labeled help for most beginner questions. I'm surprised I couldn't find a video or example for shooting. It's such a common thing that I see used or asked about almost every week.

    Basically just pick a button, connected to an emitter, and the emitter will spit out whatever object you want from the select menu. Just adjust the force and it'll spit out whatever object like a projectile, and just connect the button to an animation too, after you make one. If you don't already have a bullet object made, make a bullet object, make sure that it is movable and you probably don't want it to be affected by gravity, then have the emitter select that object. Pressing that button you chose should play an animation and emit at the same time.
  • Thank you so much! I was also confused by the fact that this website doesn't have many resources for the topic of shooting.
  • Sorry for the trouble, but would you also know how to make a bullet move slower?
  • The emit force property in the emit behavior gives an initial force to the emitted object, and since your Rock Buster object has no drag (friction with air) it will just float forever. Since your object is small (so very light), a small force can already cause a very high speed. The default force is 2, but changing it to 1 doesn't change a lot, and 0 won't even move the emitted object.

    So another solution is to set a velocity speed in your Rock Buster object:

    Image1

    And also do this in the emit behavior block:

    Image2

    Something you should also fix is moving your sprite to the middle of the canvas:

    Image3

    Don't forget to move the shooting animation too.
  • edited June 9
    Oh my god, you sir are a genius. Thank you so much for your help. Something I'd also like to note is how to make the bullet spawn in front of me.
  • Oh never mind, i just noticed that I had to change the force value to 0.
  • You're welcome.

    Forgot that red square in emit force, sorry for that.
Sign In or Register to comment.

flowlab.io

| make games in your browser
@ 2017 Flowlab.io, All rights reserved.

Contact us

Get In Touch