![]() ![]() Step 92: Here's where we put the Kill Self block (under Actor > Properties, if you recall). Step 91: Now we add a " Less Than Or Equal To" block (under Flow -> Conditions again, it looks contains a " Getters) is less than or equal to 0 or not. Next, drag an if block inside the Always block (in Flow -> Conditions in the Palette). To start, click the + Add Event button, mouse over Basics again, and select When Updating. Step 90: Finally, we need to add an Event that checks the number of Health Points the Enemy Ship has left and destroys it if it has 0 (or fewer, in case it gets hit more than once very quickly). Switch the "increment" field to " decrement", and select " Health Points" in the number field (if not there already). Switch back to the Enemy Ship's Custom Event, and then grab the Increment Number By block (found in Numbers & Text > Math in the pallete) and put it inside the custom event. Step 89: Now that each Enemy Ship will have 3 health points when they're created, lets do some damage to them when they're hit. Click on Attributes -> Setters in the Palette and drag over the Set Health Points to block, snap it inside the When Created Event, and type 3 into the empty field. Step 88: Now lets actually set the initial Health value. Create a When Creating Event (click + Add Event, then mouse over Basics, then click When Creating). Step 87: Add another event to the Enemy Ship. Step 86: Create a new Attribute, select Number for its type, and name it Health Points (click the Attributes button on the Palette, then the Create an Attribute button). To track how many hits it can take, we're going to need an attribute to store a "Health" value. However, we actually want the enemy ship to take multiple hits. Now, if the enemy was just going to take one hit and be destroyed we could put a kill self block in here and be done with it. This will cause the previous "tell" block we added (to the bullet) to trigger any code that we put in this event when triggered. Step 85: The event wrapper will appear, in the blank field type "Hit". Click Add Event and select Advanced > Custom Event. Step 84: Switch to the Enemy Ship actor and access the Events tab for it. The event should look like the image below. Type "Hit" into the text field, and then grab the blue Actor Of Type block from the collision event wrapper above and insert it into the Actor spot. We're going to use the same collision to also tell the Enemy Ship that it was hit by a bullet.įrom the palette, find the Trigger Event in all behaviors for block (found in Behavior > Triggers) and snap it above the Kill Self block (we want it to be triggered first). ![]() ![]() Step 83: While still in the Bullet's events we should be looking at the Actor - Type collision event. Now we put those bullets to use! We want to give the enemy some health so it can take a few hits, and then destroy it once it takes too much damage. Comments Crash Course 2: Invaders - Part 12 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |