Hyper-noob question: firing a MM-syle bullet

tirkaro

  • *
  • Posts: 9
Just one bump can't hurt.

I ultimately gave up on modifying the Gun Firing behavior, and went to doing the honestly more sensible route of modifying the "walking" behavior. I made all the animation attributes for everything(Namely, a firing left and right attribute, and the same for firing while shooting.) but I've been having serious trouble placing everything correctly, and everything comes out like a complete mess.
My current Walking setup is now the same as the default, so it shouldn't be too much trouble to figure out. Once again, pardon my utter noobishness. ´;ω;`

jamesvhyde

  • Posts: 25
Another place to look at examples is the Action RPG template game. (Create a new game and choose Action RPG; I think that's what it's called.) The Sword Attack behavior has attributes that control exactly where the sword appears relative to the player actor. This is necessary because the handle of different "swords" (weapons) may be at different locations relative to the animation.

tirkaro

  • *
  • Posts: 9
Another place to look at examples is the Action RPG template game. (Create a new game and choose Action RPG; I think that's what it's called.) The Sword Attack behavior has attributes that control exactly where the sword appears relative to the player actor. This is necessary because the handle of different "swords" (weapons) may be at different locations relative to the animation.

I tried that, but there's some problems with it: To make the animation noticeable, I have to stop the actor completely for a few microseconds(which I don't want) and I have no idea how to fit in different animations for firing in the air and while walking. (Remember, I have the basic mechanics perfect, I just need to apply animation to it all.)



anyway, I'm currently trying to modify the "Walking" behavior to little success. My first priority is shooting while moving right. However, when I try to put it like that, the animation only flashes for a nanosecond before going back to the normal walking animation. Even when I hold the fire button down, the only real effect I get is the still first frame of the walking animation and tiny, nanosecond-long frames of the "walking while firing" animation.

I feel like I have this by the skin of my teeth, but I just can't figure it out! (╯°□°)╯

coleislazy

  • *
  • Posts: 2607
If the animation is flashing for only a second, its likely that something is changing the animation back before it finished playing. Its probably your walking behavior or an animation manager (if you're using one). You'll probably have to modify them to work with your new state (running and shooting), like they handle other states (jumping, falling, etc).

redpesto

  • Posts: 134
Can I piggyback on this thread as its pretty much the same thing.

I'm making a shmup and the ship idles a lot. So I have it firing to the right but am struggling with firing to the left. How do I detect if the ship is facing left or right but not necessary with the key being pressed down?


This looks good to me but I don't understand how to make the '<if direction = right>' line in Design Mode...

{Always}
    <if key is pressed>
        [create bullet actor at (x,y)]
        <if direction = right>
            [set x-speed of last created actor to (number)]
        <otherwise>
            [set x-speed of last created actor to [negate (number)]

« Last Edit: July 29, 2011, 10:40:27 am by redpesto »

tirkaro

  • *
  • Posts: 9
Can I piggyback on this thread as its pretty much the same thing.

Be my guest 9_9

Anyway, YES, I got the animation working. What I had to do was change the "if" command where it says "Move Right Key + not Move Left Key = Walking" to "Move Right Key + (Not Move Left Key + Not Press Fire Button) = Walking."
Now I just have one, teensy weensey last question here, that I've tried my darndest to figure out:

To keep firing my character's weapon, you have to keep on mashing the Fire Button. Which is swell and all, but when you do that while running, it just plays the first frame of my character's "Running and Shooting" animation over and over again, making it look like he's stuck in the same frame while doing that. Any way I can fix that?


This is how I currently have my attack animations set up within the Walking behavior. (I didn't make the "Walking while shooting left" command yet.)

jamesvhyde

  • Posts: 25
Redpesto, you have to keep track yourself of which direction the ship is facing. You can do it using a hidden attribute as I explained in this comment:
One way to do it is the following...
You update the direction value whenever the key is pressed, and then you can use the direction value whenever you want. Let me know if you need further clarification.

redpesto

  • Posts: 134
Right, I tried to used the 'direction' attribute and its making things really messy. I'm using the 4-way behaviour and a shooting behaviour I made called Fire.

I've attached a screenshot below.

Currently it always fires to the left (-70). Do I set up the direction attribute just for the4-way behaviour?

I'm a bit lost now :'(

jamesvhyde

  • Posts: 25
It's a little messy, but I wouldn't call it "really" messy. Creating interesting behaviors will always require adding some amount of code. You are on the right track with this. One question--are you using the 8-directional (diagonal) option with the 4-way behavior? If so, your "if" blocks that check the value of "direction" are never getting checked, because they are inside the "if not 8-direction" blocks.

redpesto

  • Posts: 134
Ahhhh.... I see! Let me try and fix that!

Edit: Hmm.. now I don't know where to put the 'set direction right' code. Maybe it will be best to write my own 8-way that just does what I need.

Edit2: So, I've moved the 'set direction right' code up above "if not 8-direction" and it still not working. If I check check Right and leave the next bit as otherwise it always fires left. If I also add a If 'set direction left' - the bullet just freezes.

« Last Edit: July 30, 2011, 01:27:25 pm by redpesto »

jamesvhyde

  • Posts: 25
I am not surprised the bullet freezes if you put an extra "if" in the Fire behavior. It appears that the value of the direction attribute is never getting set.

Your fix in Edit2 sounds like the right thing to do; it's hard to say why the value of "direction" is not getting set. One thing I think you should do is to give the direction attribute an initial value. Do this in the "when created" block in the Fire behavior. Set direction to whatever the starting direction the player is in. I doubt this will fix your problem, but at least it will let you control which way the bullet goes, so it won't just freeze.

If you still can't get it to work, the next thing I would do is check the console to see what's going on. If you hit ~ in the flash player, the console messages will appear. If there is an error about a null reference, something is going wrong with your behaviors and we'll have to figure out where the problem is. You can also print the value of the direction attribute to the console using the "print" block. It's under Debug under Flow.

Edit: Actually, looking at your screenshot, it looks like your "direction" attribute is in the 4-way movement behavior, but you're trying to use it as if it's in the Fire behavior. Make sure you have a "direction" attribute in the Fire behavior.

« Last Edit: July 30, 2011, 04:23:33 pm by jamesvhyde »

redpesto

  • Posts: 134
I'm working on a different game this week but will get back to this one later - just wanted to say thanks for your response :D