182,376

Views

Beginner

Level

67

Comments

Crash Course 2: Invaders - Part 11

by Hectate (Updated on 2015-05-02)


Part 11: Destroying Bullets

If we didn't do something to remove Bullets from the game correctly, it might eventually affect performance (assuming the player shoots as much as we expect them to). Lets set something up to destroy our Bullets at a couple of key times. Switch to your Bullet actor type's Event tab.

Step 78: Add an Actor of Type Collision Event (click + Add Event button on the left, then select the Event, as shown).

Step 79: Set the Actor Type to Enemy Ship, then drag over a Kill [Self] block from the Palette (under Actor -> Properties).

Now each Bullet Actor will be destroyed when it collides with an Enemy Ship.

Step 80: Next, to ensure our Bullets are also destroyed when they leave the screen, we need to add an Actor Event, when a Specific Actor Enters or Leaves the Screen, as shown:

Step 81: Change the dropdowns on the Event block that appears from enters to exits, and from scene to screen, then drag over a Kill [Self] block (Actor -> Properties in the Palette).

If you were to test your game now, you would probably notice that the bullets don't get destroyed when they collide with the enemies. The reason for this is that the collision group for the bullets is not set to collide with the enemies.

Step 82: Select the Bullet actor type's Properties tab, and make sure that the Group is set to Bullets. Then click "Edit Groups". The Collision Group section of Game Settings will open up. Make sure that the "Bullets" group is highlighted to the right and then click the "Enemies" group so it turns green (as in the image below).

http://static.stencyl.com/help/images/bullets_collision_group.png

Save your game and test it; now the bullets should be disappearing if they collide with the enemies. Next, it’s time to set up what actually happens when Bullets collide with the Enemy Ships, instead of just removing the bullets from the game.

Click here to go to Part 12.

Disclaimer: Use comments to provide feedback and point out issues with the article (typo, wrong info, etc.). If you're seeking help for your game, please ask a question on the forums. Thanks!

67 Comments

amritnagra22
I want my bullets to shoot from the ship's cannons
0 5 months, 2 weeks ago
Mr BLOB
if the bullet is moving slow go to events in ship and go to the event that makes the bullet move there will be an option for sharply or gently select sharply they dont say this but show it in a picture
0 6 months, 2 weeks ago
amritnagra22
bullets moving to slowly
0 1 year, 1 day ago
Chris24XD
https://chris24xd.itch.io/stencyl-i nvaders-fixed-solution
Also Chris24XD 2 is my alt account.

0 1 year, 3 months ago
Chris24XD 2
Use this image for fixing events:
https://img.itch.zone/aW1nLzMyNjE3N zMucG5n/original/s7KyLW.png
*l FINALLY FIXED THE WHOLE GAME*

0 1 year, 6 months ago
vishwa12345
I've got Stencyl 4.0.2 version. When I open the 'Bullets' group, I see that the 'Enemies' group is green, for the collisions. And, I see the 'Bullets' group highlighted when I open the 'Enemies' group for collisions. Yet, when I run the game, I see that the bullets do not disappear when they collide with an enemy, nor do the bullets disappear when they go off the screen! Somebody, PLEASE help me...
-1 1 year, 6 months ago
Chris24XD 2
@Chris24XD 2 Sorry wrong 1 attribute for Bullet and 1 for Enemy Ship (l'm really sorry...)
1 1 year, 7 months ago
Chris24XD 2
@Chris24XD 2 Oh... and you have to make a custom block like it will say Kill [ Actor Type ]
-1 1 year, 7 months ago
Chris24XD 2
@Chris24XD 2 Also change the Actor of Type event with Type - Type event That's too important!!!
-1 1 year, 7 months ago
Chris24XD 2
Tip: If you have problem with killing Enemy Ships and Ship just create 2 attributes (1 for Ship (Actor Type) and 1 for Enemy Ship (Actor Type))
-1 1 year, 7 months ago

Sign In to Comment