Creating abilities for your game lets you change how players play, and give them super powers! In this lesson, you will make an ability that lets players create an object in game.
The examples will focus on creating something like the Barrier Orb wall from Valorant.
Abilities and Equipment mean different things in lots of different video games. As Core objects, however, they are packages that come with built-in utility.
In Core, an Ability is something that a player can do by pushing a button, with an associated player Animation. They have properties that you can change to say how long a player has to wait between uses, and how long it takes to activate it, as well as choosing the button and animation. Abilities also create events, so you can write code for what should happen when they are activated, while they are being used, and afterward.
You can learn more about properties and events of abilities in the Ability section of the Core API.
Equipment in Core is something that can be picked up, and gets attached to the player. These can have associated abilities, which would enable players to use the equipment in some way. You can learn more about the properties, events, and methods that you can with Equipment in the Equipment section of the Core API.
In this lesson, you will create an ability, and learn how to give that ability to a player with equipment, and with a general script. We will start with equipment, because it is easy to start testing right away.
In the Gameplay Objects category of Core Content, find the Equipment object and drag it into the scene.
Equipment starts out with just an empty trigger, so you should see the outline of a small box.
If you do not see the box, press V to enable gizmos.
To pick up the equipment in game, you will need a way to see where it is. Select any 3D object to represent your ability, and drag it onto the Equipment object in the Hierarchy.
This example used the Ball object.
Once you have added the object to the Equipment, select it in the Hierarchy and open the Properties window. In the Scene section, set the Collision property to Force Off
Press Play to test out your equipment. Run over the object in the scene. It should automatically attach to the player’s head.
Sage from Valorant
If are suddenly unable to move once the object equips, you still need to disable collision on it.
In Gameplay Objects section of Core Content, find the Ability object, and drag it into the Equipment object in the Hierarchy. If an ability is the child of an equipment, it will automatically be given to a player who has that equipment on.
Press Play to preview the game again. Once you run over the object and it is equipped, trying pressing the left mouse button. Your character should perform a slashing motion.
Select your Ability in the Hierarchy and open the Properties window.
The Ability section has several customizable properties for the ability.
Change the Action Binding property to change the button press the player uses to activate it. You can see the all the names for different buttons in the Ability Bindings section of Core Documentation.
Change the binding to Extra Ability 22
to bind it to the E key.
The animation will determine the movement the player character does when the ability is used. You can find a list of all the current player animations in the Player Animations section of Core Documentation.
You can test any animation by changing it here, and then trying it out in game with the object equipped. For this example, we will use the unarmed_magic_up
animation.
There are several more sections in the properties of an Ability, which refer to different stages of using it. You don’t need to change these now, but altering these options can help you make your ability look and work the way you want it.
The phases are:
In the example for this project, we are going to create the ability to conjure a wall from thin air, in the game. If you have made a map a shooter game, you can probably imagine how easily overpowered the ability to add in another wall would be.
The first step is to create a wall. This can be anything from an elaborate castle piece, or a cube with a material. The example here is made up of four rounded cubes with a customized ice material.
Ice Wall
tells you everything you need to know.You can now delete this wall and easily add it back in from Project Content, or keep it there for editing later.
The next thing we need to do is to create a script for the ability behavior. Core’s Script Generator has an option specifically for Abilities, which we can use here.
ConjureWall
ConjureWallScript
.When you create a script, it is placed in your Project Content, not the Hierarchy.
local propIceWall = script:GetCustomProperty("IceWall")
in this example.You will use the script to spawn the wall during the correct event phase of the ability.
function OnExcute_ConjureWall(ability)
in this example)local conjuredWall = World.SpawnAsset(propIceWall)
Code language: Lua (lua)
Press Play to test out conjuring a wall. You should create one, but only at the point (0, 0, 0) of the space.
To make the wall appear where the player was aiming, you can use the AbilityTarget which has its own section of the Core API. This can give us a variety of information about what was happening when the player used the ability.
Add the following lines to the OnExecute_ConjureWall
function to move the wall into the right place:
local targetData = ability:GetTargetData()
local wallPosition = targetData:GetHitPosition()
local playerDirection = targetData:GetAimDirection()
local conjuredWall = World.SpawnAsset(propIceWall, {position = wallPosition})
conjuredWall:LookAt(ability.owner:GetWorldPosition())
Code language: Lua (lua)
Too keep the walls from last forever, you can add a Life Span to the spawned Wall asset.
3
. You can increase this later, but a shorter time interval makes it faster to test.You should now be able to test spawning walls that disappear after 3 seconds.