In this tutorial, we'll be building upon what we learned in the first tutorial. If you haven't read through that tutorial yet, please take a second to do so. In the previous tutorial we saw how to create an Ability and play it on a character. However, what if we want our Ability to affect others? In this tutorial we'll be doing just that.
Topics we'll cover include:
Our goal will be to take our LetsParty Ability and change it to affect everyone around us in a radius in a new Ability called EveryoneParty.
First thing we need to do is create a new Ability, inherit from our standard AblAbility class, and name it EveryoneParty. If you don't remember how to do that, take a quick look back at LetsParty tutorial.
Now, the first Task we are going to add is actually going to be a Collision Query Task. This Task allows us to query the collision scene using a simple shape. If you aren't really sure what Collision is, feel free to check out the official documentation.
This Task will actually be in charge of finding our targets in the world (Note: You could also do all of this with a Targeting rule). Let's go through setting our properties on this Task.
Now, Add in our other two tasks: Play Particle Effect, and Play Sound. If you remember from the 1st Tutorial, these Tasks will play our confetti effect and our party horn. They're set up the exact same from the previous with one very important change, we're going to set our Task Target to Target Actor.
Tasks all have a Ability Context Target Type they use to determine who to affect. There are 4 Ability Context Target Types:
Task Targets let a single Ability affect multiple actors where previously you would need to one Ability to apply the same Ability to multiple targets. Able will let you do that as well, however there is more overhead with that approach as you'd have N Actors running an Ability versus just one for something pretty simple (like this Ability). That said, there is a fine balance. Make sure you aren't making "Uber Abilities" that do everything when you can split that over one or two Abilities. For example, if I wanted to make an Ability where the character did 10 Jumping Jacks and then exploded - I would make a Jumping Jacks Ability (set it to loop 10 times) and then branch to the Explosion Ability. There's no "right way" to make an Ability so feel free to play with things and find what works best for you.
Before we move on, feel free to check your settings against the screenshots to make sure you have everything set properly!
Now there's one more thing we need to set. All our Tasks are set to occur at the same time (0.0 Seconds). However, since we need our Target Actor Targets, and those won't be ready till after the Collision Query is completed, we need to change things a bit so everything works properly. There's two options: We could move our other Tasks out to a time when we expect Collision Query to be done (say, 0.1 Seconds), or we can use a feature in Able called Task Dependency. A Task Dependency simple says that a Task requires another Task to be completed before it's able to execute. That's exactly what we want, so let's set it up!
Right click on the Play Particle Effect Task and you'll see an option called Dependency and a list of other Tasks. Select the Collision Query Task and you're all set! You should now see a Link icon on the Collision Query whenever you have the Play Particle Effect Task selected. Do the same thing for the Play Sound Task and you're all set.
You're all done! If you want, turn on the Show Collision Queries option (under the Timeline menu) and hit Play. You should see the query happen and the particle and sound play above your head. Set your Party Guy ability to your new Ability and throw a few more entities in the level. Run around and show everyone how to party!