Everyone Party - Creating an Advanced Ability

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:

    • Collision Queries
    • Copy to Context
    • Task Targets
    • Task Dependencies

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.

Click to enlarge

Click to enlarge

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.

  • Query Shape
    • Set this to Sphere for simplicity sake. But feel free to try other shape types and experiment.
  • Radius
    • The size of our sphere. Set this to 600 units (~6 meters).
  • Collision Channel
    • Set this to Pawn. This is the channel we'll be checking our shape against. See the official documentation for more details on Collision Channels.
  • Filters
    • Add 1 Filter By Class filter and set the class to Character, and enable Negate.
      • This will filter out all results that aren't inherited from the Character class. The Negate option makes sure we only keep those Actors rather than discarding them.
  • Misc
    • Set Copy to Context to true. This will copy the results of our Query into our Ability Context. More on this in just a bit.
  • Realm
    • Lastly we set our realm to Client because all our Tasks are going to be Client tasks so it doesn't make much sense to run this on server when it won't be able to do anything (Servers don't play particle effects or sounds normally), if you aren't running a networked game - then don't worry about this field. 

Click to enlarge

Click to enlarge

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:

  • Self
    • This is the Actor executing the Ability.
  • Owner
    • This is the Actor who "owns" the Ability. This is set when constructing the Ability Context.
  • Instigator
    • This is the Actor who instigated the Ability. This is set when constructing the Ability Context.
  • Target Actor
    • This is the Target(s) of the Ability and is normally set through using a Targeting rule. However, remember our Copy to Context option in the previous step? That option copies all the results from our Query and stores them in the Target Actor Target Type. In short, Copy to Context lets you add Targets to an Ability after the Ability has already started. This lets you construct complex collision queries for your Ability at any time and access the results without going through Blueprints/C++!

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!

Click to enlarge

Click to enlarge

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.

Click to enlarge

Click to enlarge

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!