Abstract declares the class as an "abstract base class", preventing the user from adding Actors of this class to the world in Unreal Editor or creating instances of this class during the game.
Blueprintable allows this class to be added onto or modified in the Unreal Editor through the use of blueprints. This makes working and tweaking the class much easier.
GENERATE_BODY() must be the first thing inside any class header.
What we are talking about today is the 'UPROPERTY'. Prefacing a variable with 'UPROPERTY' tells the Unreal Engine that you want it to know about this variable. Inside a 'UPROPERTY' are tags that further define how you want the engine to handle this variable. Lets create a variable for the explosion visual, we'll call it 'ExplosionTemplate'. In our example we have the 'EditDefaultsOnly' and 'Category = Effects' tags in the 'UPROPERTY'.
EditDefaultsOnly tells the Unreal Editor that only the default value for this variable can be changed in the editor. This means that this variable cannot be changed during gameplay.
Category = Effects helps us organize the 'UPROPERTY'. We told the Unreal Editor to put this variable under the 'Effects' category. We could have set the category to anything we wanted. If the category didn't previously exist then it would create it. If the category already existed then it would simply add this variable to the other in the category.
*Notice that I added a new class called 'ArenaExplosionEffect'. I quickly created this class for the purpose of this tutorial. We will cover it more in a future tutorial but basically it is a classes that defines how the particle FX of the explosion will look. I just wanted to point that out in case it confuses anyone. Lets build the code!
Now that we have compiled the code and are in the editor, lets create a grenade blueprint. Navigate to the 'Blueprints' folder and open the 'Weapons' folder. This will be a good place to put our grenade blueprint. We will then right-click on any blank space in the content browser. Then, from the pop-up menu click 'Blueprint' which will start a setup wizard.
All blueprints need to inherit from code. When it asks us for a parent class we are going to look for our 'ArenaFragGrenage'. We can simply type the name into the search bar to find it easily. Once you have located it, click it and then click 'Select'.
It will give our new blueprint a default name. Lets right-click on it and select rename and call it 'Arena_FGrenage' this will help us to identify it in the future. If we double-click on it, it will open up the blueprint.
With the blueprint open we can navigate to the 'Defaults' tab. If you recall these are the values we are able to edit with the 'EditDefaultsOnly' tag. At the top we see a category called 'Effects' with a variable called 'Explosion Template'.
Here we can find our 'Arena_FExplosion' blueprint (that I previously created for this demo) and assign it to this variable. This will tell our grenade class to how to look when it explodes. There are still a couple steps missing in order to get the grenade actually working. In the next few tutorials we will learn how to interact with a 'UPROPERTY' and how it greatly simplifies the code. Click 'Compile' and then 'Save'.
No comments :
Post a Comment