So I’ve implemented a basic mana attribute that is reduced when the player attacks. The first test I wrote was a blueprint test were I was checking the mana reduced as expected when attacking, this didn’t take very long to implement in blueprint. However, I am now trying to implement the same test in cpp.
I started with a simple test however my character is a BP actor and I was unable to spawn it in the same way I was for the spec test so for now I’ve switched to the spec test. I’ve got the player spawning but when I try access the attribute set to get the value of the Mana attribute I’m getting an access issue and in debug the attribute set is Null (I’m using the get function created in the attribute set through the macros). I added a log to the character’s begin play where the attribute set is assigned but that’s not being called during the test.
Again I’ve run into a similar issue that I’ve had before and I have to assume that tests don’t tick because I cant find anything about this online. I’ve tried to use the world->tick function to get the begin play to run. Which doesn’t appear to work as I’m not getting the log and my It function doesn’t appear to run but the test still fails. Going to try again but by using world->SetShouldTick(true). This also has not worked, character was spawned but Access violation when trying to access the attribute set to get the value of mana.
I decided to create a new map that’s empty and load that instead of creating it during the test, The begin play for my character appears to run now as I’m getting the log (so maybe I’m just creating the maps incorrectly for my tests) unfortunately I’m still getting an access violation and the attribute set for the character is still Null. Whilst this was compiling I did find another way to get the attribute value so I’m going to try that way( GetNumericAttribute function through the ability system component), I also came across “AbilitySystemComponentTest.cpp” so I’m going to have a read through that and see if there’s anything useful in there. Well GetNumericAttribute worked :).