Trying to work with Lyra. Unable to do simplest thing: Create a cube that can be damaged.

I want to add a thing that can take damage. That’s it. A simple cube that can take damage.

You would imagine this is a 5 minute job if that considering this is a) conceptually brain dead simple and b) lyra is touted as a great starting point with super clean modular code

…but here i am, many hours later, feeling utterly depressed.

After a while (due to pure luck and grim determination, not because it was well documented) i have figured out that if i create an actor (blueprint), give it a “Lyra Health Component” and an “Ability System Component” then the “ULyraDamageExecution::Execute_Implementation” function will be called in the LyraDamageExecution.cpp class

How we get to LyraDamageExecution.cpp i have no idea but what i do know is that when i shoot my cube and we arrive at this function the health is already at zero. I try to set the health in the health component but you can’t do that.

For… some reason… the way that initial health is set, at least in terms of the mannequin that comes with lyra, is to have a “Lyra Ability System Component” constructed and then pass that in to the “InitializeWithAbilitySystem” function of the “Lyra Health Component” which will eventually set the “HealthSet” of the “Lyra Health Component” to the return value of “AbilitySystemComponent->GetSet();” which… does… something…

alright, getting lost, lets just copy whatever they were doing in the mannequin to my cube: i go to my cube actor blueprint and on begin play i call “initialise with ability system” on the health component passing in my ability system component… aaaand you can’t do that. it needs to be a LYRA ability system component

ok so lets change the “ability system” of my cube to a “lyra ability system” and see where we can get to…and “lyra ability system” is not blueprint spawnable.

right… set the metadata for the uclass to make it spawnable… feels like i’m not doing it right… but whatever i can make a lyra ability system component now. So i add it to my cube, i can call the “initialise from ability system” on the “begin play” event of my cube…

and it fails saying the ability system health set is NULL

so somehow i need to create a “lyra health set” now? but that also is not available? Or i am missing some knowledge surrounding it idk.

at this point i am almost certain this can’t be correct so i stopped to write this post explaining my unreasonably long and arduous journey to create a f-ing cube that can be damaged.

please help i am going insane.

5 Likes

So i think essentially the crucial information i was missing was: it is a fools errand to try an implement gameplay ability system in blueprints.

Doing basically what i did in blueprints, but instead doing it in a c++ class and i was able to create a LyraHealthSet in addition to my LyraHealthComponent and LyraAbilitySystemComponent and with all 3 of these in place and calling HealthComponent->InitializeWithAbilitySystem(AbilitySystemComponent); on begin play - everything just kinda worked.

Well, i got it to take damage, but cannot get it to react to death events. Nothing i have tried so far works. I can’t for the life of me see anywhere in the lyra project where it registers anything to do with death events. It might as well work by magic on the LyraCharacter for all i can tell.

It blows my mind how much effort this is to implement. Is it really so much to ask for documentation or… something… anything. :frowning:

Lyra Death is an Ability. Make sure you are applying the ability to the actor. You are correct about the health set. It is added to the actor via the LyraCharacter parent. The components also need to be called in the Playerstate.cpp file.

I don’t mean to be awkward but can you provide an example of HOW i would go about doing that?

It is not at all obvious, documentation is non existant and Lyras code on top of gameplay ability system is… something else entirely.

Lyra just expects everything to be a pawn. If it’s not a pawn, Lyra isn’t interested in it. None of lyras code expects an actor to have an ability system.

I’m really, really confused and the complete lack of documentation or explanation for anything is just terrible :frowning:

Well, i ended up not registering the ability directly because i couldn’t figure it out but instead i created an “ability set” which contained the ability then made a uproperty for my cube to contain an array of ability sets, such is the way that other abilities in lyra are implemented.

i can now get my cube to be shot and die.

but now, of course, because NOTHING is easy, it won’t replicate over the network. as the client, i don’t get damage numbers popping up, nor does it do anything when the cube dies. it does die on the server tho.

extreme sadness. also losing hope that anyone will read this post let alone be able to help me.

Haven’t tried abilities yet. Trying FPS camera… but hope this overview helps:

Did you figure this out? I’m struggling with things that I was considering easy as well. I thought I will make Lyra Experience from the scratch but…I’ve a very similar to your experience instead. I’ve spend days… I feel that’s a terrible answer but:

Using Lyra feels very distant from programming - it’s rather figuring out by poking stuff without documentation. I feel like I’m spending my time in vain. This is not a one “can’t add ability set” case this thing will continue on and on - on each new level of system that will be implemented in the engine. It will be always like that.

So as much frustrated I am I want to do things on a lower level of abstraction on my own. Otherwise I’m betting huge amount of time on poor docs and won’t be able to actually use benefits because they will be constantly changing or broken or not exposed to BP . And in the end even if I will figure out this - I will not learn anything from it - next time it will be some different thing. I will extend in a brutal way existing classes, copy past them and the rest I will actually program as I did using UE4.

To do this in Lyra requires using the Gameplay Ability System.

Health is an Attribute. For something to have health, it must have a Gameplay Ability System Component and it must have a Health Attribute Set.

Lyra has a sample C++ class ALyraCharacterWithAbilities that you can refer to. If you make a Character based on this class, you will quite easily be able to view its health, damage it and kill it.

If you want to make a cube (random non-character actor) that can take damage, then you will need to add some code to your cube like Epic did in ALyraCharacterWithAbilities. Make an Actor, give it an ASC and a Health Set, make sure you initialize everything correctly.

Once you have a Character (or other Actor) with an ASC and a Health Attribute Set, then applying damage to it is done by applying a Gameplay Effect. For example see GE_Damage_Melee in the ShooterCore GFP. You can heal and do other things using Gameplay Effects as well.

This is complex not because it’s Lyra, but because it supports multiplayer over the network via GAS. Any project using GAS to support multiplayer would be a similar setup.

I created a BP based on LyraCharacterWithAbilities

Is the Ability System Component you mension the same as Gameplay Ability System ?

I tried to see if I could initialize a LyraCharacterWithAbilities and play with its Health, but Health always return 0. You write initialize everything correctly? What am I missing?

Anyone figure out how to damage a cube yet?

I can make a cube damage a player but not the other way around.

Okay here we go.

Thank you so much. It works.

Btw do you know how to assign a team to this cube so the player in the same team can’t damage the cube?

1 Like

I haven’t figured that one out yet. It’s on my wishlist as well.

Has anyone tried to do @Astaraa tutorial using C++?

I’ve tried making a child class of ALyraCharacterWithAbilities and then overriding the PostInitializeComponents() function. Finally, I added this inside it:

GetAbilitySystemComponent()->InitStats(ULyraHealthSet::StaticClass(), NULL);

I’ll add the datatable later once I actually manage to init the health component, but I haven’t been able to make it compile. Does anyone know how to do it?

This is how to do it in C++. There is a video linked at the top of this post:

Thanks @xi57 !! I actually found that documentation page earlier today and tomorrow I’ll probably review the example code you provide, I’m sure I’ll learn a lot :slight_smile:

For now the linking error that I was having went away when I added LYRAGAME_API to LyraHealthSet and LyraCombatSet. Like this:

1 Like

Hi, I found another simler way to do it, needs some polishing but the concept is pretty straight forward: Lyra Health on simple Actors | Community tutorial