direction problems on "fire bullet" behavior

ac3raven

  • Posts: 19
I'm using the "fire bullet" behavior for my player character so that I can pick up berries and throw them.

In the configuration options for the behavior, I can choose one of the cardinal directions to determine which direction the bullet will go upon firing.  It's suppose to be relative to the direction of the player, but it fires in the same direction regardless of player direction.

I do not have absolute direction selected, so that's not the problem.  What could it be?

captaincomic

  • *
  • Posts: 6108
Is your player character rotating or changing animations?

The Fire Bullet behavior was written with a game like Asteroids in mind, where the space ship rotates. For platformer games where the character always has the same angle, but changes animations for left/right, the behavior has to be slightly modified.

A simple check
<if <<current animation for <self>> = <left animation>>
  <increment <Fire Direction> by <180>>

might be all you need to add.

Anyway I'll add an option to change the fire direction based on animations in the next update.

wishy

  • Posts: 33
Hi,

I tried this out recently with the same results. Cptaincomic; when you mention the next update, are you referring to Stencyl 3.0?

Also, if I were to attempt to put the check you mention in to a behavior myself, where would it go?

Thanks

« Last Edit: January 29, 2013, 01:14:01 pm by wishy »

captaincomic

  • *
  • Posts: 6108
Hi

Yes, I added this to the 3.0 behavior. It should work with 2.x as well, so I attach it here. It works a bit differently from what I posted here. You have to select "Use Animations" and then enter part of the names of the animations in the attributes. For example if you have a "Walk Left" and an "Idle Left" animation, you would enter "Left" in the field of "Left Animations".


wishy

  • Posts: 33
oh wow, thanks!

but..

I can only see a .png image file attached!?

captaincomic

  • *
  • Posts: 6108
Yeah, it's the behavior (stored in the metadata of the image.) You can import it in Stencyl, just drag it into the behaviors page.

wishy

  • Posts: 33
Ah! Great, thank you!!

Side Note:
I had to remove the older 'Fire Bullet' behavior from my game in the Actor Behavior section of my game, that is to say, the import didn't overwrite by default.

Cheers


UPDATE: looks like it didn't like the Animations checks, heres the output. For the record, i've created/named some animations to match the behaviors requirements.


Behavior: Design_26_26_FireBullet at line 146
Call to a possibly undefined method equals through a reference with static type String.
                        if((!(String(_UpAnimations).equals("")) && (String(("" + actor.getAnimation())).indexOf(_UpAnimations) >= 0)))

Behavior: Design_26_26_FireBullet at line 152
Call to a possibly undefined method equals through a reference with static type String.
                        else if((!(String(_DownAnimations).equals("")) && (String(("" + actor.getAnimation())).indexOf(_DownAnimations) >= 0)))

Behavior: Design_26_26_FireBullet at line 158
Call to a possibly undefined method equals through a reference with static type String.
                        else if((!(String(_LeftAnimations).equals("")) && (String(("" + actor.getAnimation())).indexOf(_LeftAnimations) >= 0)))

Behavior: Design_26_26_FireBullet at line 164
Call to a possibly undefined method equals through a reference with static type String.
                        else if((!(String(_RightAnimations).equals("")) && (String(("" + actor.getAnimation())).indexOf(_RightAnimations) >= 0)))

« Last Edit: December 31, 2012, 09:25:21 am by wishy »

captaincomic

  • *
  • Posts: 6108
Hm, okay, I don't know why it doesn't like the "_ is empty" block. Here's a version that should work with 2.x.

wishy

  • Posts: 33
Hi, I know I havent responded to this thread in a while but just some feedback: the attached behavior only seemed to shooting 'up' even after being configured.

Cheers

captaincomic

  • *
  • Posts: 6108
Okay, how did you configure it, which values did you use for all the attributes?


wishy

  • Posts: 33
Hi,

i've attached a screenshot showing what i've visually set the behavior to, everything not in the shot is default (except for 'Use The Mouse' which i've un-ticked).

i've also attached the behavior's code after with the settings set as I thought that might be of more use to you.

Sorry to drag this out, and thanks for the support!

captaincomic

  • *
  • Posts: 6108
Hm, okay and how are your animations called? Do they contain the text "move_up", etc.?
Edit: If you don't mind, you can also attach the game and I take a look.

« Last Edit: January 26, 2013, 03:43:42 am by captaincomic »

wishy

  • Posts: 33
Hi Captain!

the animations are named exactly as the references in the field values. I'm at work at the moment but will certainly attach the game when i get home.

Cheers

wishy

  • Posts: 33
just as an aside, will Stencyl 3.0 come with more built in behaviors?

I love the idea of being able to use the 'out-of-the-box' resources with Stencyl and would love to see some generic game style packages/behaviors.

Will Jon (or another member of the Stencyl team) be posting an update on that topic?

thanks again

wishy

  • Posts: 33
Hi Again, i've attached the game.stencyl file (if that what you wanted?)

Cheers
wishy