Trigger Fire Bullet

sjgames86

  • Posts: 18
Hi there.  I've been stuck on this one for a few days now.  I've attached a Fire Bullet behavior to an enemy torrent.  Inside the behavior where you can assign the button/mouse to shoot the bullet, it says you can add an event to trigger the bullet.  I've tried this myself with no luck.  I want it to shoot every 2 seconds so I put:  Every 2 Seconds - Set Fire to True.  Also:  Every 2 Seconds - trigger Fire Bullet in behavior for self.  No luck.

Anyone have any ideas?

corcoranp

  • Posts: 28
Can you post a screenshot of the behavior?

Also, you said you want to make the enemy shoot on button/mouse, AND every two seconds?? which do you want it to do?

sjgames86

  • Posts: 18
Hey thanks for responding!  Sorry for the confusion.  I don't want it to be assigned to a button, ONLY to shoot every 2 seconds.  I've been messing around with the events and managed to make it shoot every time I press my mouse of the enemy gun (6th line down "Set Fire to Fire or Mouse is Pressed Down on Self".  Can I replace that code with something that makes it shoot every 2 seconds? 

sdieters

  • Posts: 2068
the easiest way is literaly nothing more but 8 code blocks.

when created,
trigger event startShooting

when startShooting happens,
create bullet at (x and Y)
set velocity to (you know how it works hehe)
if not holdShooting << this is optional if you want to pauze the shooting
~do after 2 seconds
~~trigger event startShooting

seeing your code, i think you can take it from here =)

good luck!
My new profile is TheIndieStation.
When you see a recent post with this name, i'm probably using my phone. So dont mind any typo's =p

sjgames86

  • Posts: 18
Sorry, I'm confused.  I don't see a "startShooting" anywhere. 

Also, I didn't write this code, I'm a complete noob who needs things explained out for him :)

sdieters

  • Posts: 2068
you have to create it yourself.

there is a block that says "trigger event ..." that is where you have to fill in startShooting
then if you go to "add event > advanced > custom event" you will be able to fill in "when ... happens". you also need to fill that with startShooting.
My new profile is TheIndieStation.
When you see a recent post with this name, i'm probably using my phone. So dont mind any typo's =p

captaincomic

  • *
  • Posts: 6108
If you want to use the bundled behavior and make it shoot every 2 seconds: attach it to your actor type, then in another behavior or in the events for this actor type, put
<do every [2] seconds>
   <trigger event [FireBullet] in behavior [Fire Bullet] for [Self]>
Notice that the event is called FireBullet without space, and the behavior is called Fire Bullet with a space.


Creating your own behavior is of course also an option...

sjgames86

  • Posts: 18
Thanks you guys!  Captaincomic, that worked flawlessly.  I see now that under the behavior it says "FireBullet" trigger.

That takes care of the CPU fire.   Now what if I want to trigger MY (Player 1)'s fire by tapping (mouse clicking) on a certain region or actor?

carpetguy

  • Posts: 47
Easy... you'll have to create a region in the scene editor, then use a behaviour to set an attribute to the region. Then simply say when mouse is pressed on [scene > regions > Get region > choose attribute] trigger event....
I think you'll take it from there.
Or you could get the Actor or Scene on create to create the region then use last created region instead of an attribute.

If it was an actor that is the trigger simply -- When on Actor (mouse pressed) -> trigger event ...
I AM DEFINITELY AWAKE (SORRY FOR THE CAPS, MY CAPS-LOCK BUTTON IS BRoKEN :D)

sjgames86

  • Posts: 18
Perfect!  I used the last created region thing and it worked perfectly.  Thank you so much!  The game is actually functional now :)

carpetguy

  • Posts: 47
Can you upload it to the Arcade so we can play it?
I AM DEFINITELY AWAKE (SORRY FOR THE CAPS, MY CAPS-LOCK BUTTON IS BRoKEN :D)

sjgames86

  • Posts: 18
Eventually!  By functional, I mean its basically working but not complete :)  Probably be done in August.