Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added note about AttributeSet being Transient. #70

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zompi2
Copy link
Contributor

@zompi2 zompi2 commented Oct 28, 2021

This is something me and my team encounter lately. When someone was playing a game in the editor - values inside AttributeSet changed. Then, when a character blueprint was duplicated - these changed values were moved to a new character blueprint (but as a default values).
This was leading us to some very strange and difficult to track issues.
Creating objects, that are not components inside of actor's constructor is very risky and unsafe anyway, just like binding delegates inside the constructor. The best way to mitigate such issues is to set these properties to be Transient, so they won't serialize themselves during gameplay.

I'm not sure if the written note is descriptive enough, but I think it is a good idea to note about this problem, as designers usually love to copy-paste blueprints ;)

This is something me and my team encounter lately. When someone was playing a game in the editor - values inside AttributeSet changed. Then, when a character blueprint was duplicated - these changed values were moved to a new character blueprint (but as a default values).
This was leading us to some very strange and difficult to track issues.
Creating objects, that are not components inside of actor's constructor is very risky and unsafe anyway, just like binding delegates inside the constructor. The best way to mitigate such issues is to set these properties to be Transient, so they won't serialize themselves during gameplay.

I'm not sure if the written note is descriptive enough, but I think it is a good idea to note about this problem, as designers usually love to copy-paste blueprints ;)
@tranek
Copy link
Owner

tranek commented Dec 3, 2021

I don't think I'm following what you're saying.

  • You played your game in PIE and made changes to Attribute values in an AttributeSet
  • You stopped playing in PIE
  • You duplicated the character BP
  • The new duplicated character BP had default values for those Attributes
  • I'm assuming that the default values were the values before the changes that were applied in PIE

That sounds like it's working as intended since any changes to Attributes shouldn't be saved to the CDO BP when PIE stops. I'm reading this as:

  • Played in PIE, character took 50 damage
  • Stopped playing in PIE
  • Duplicated character BP
  • Played in PIE again and character had full health instead of starting with missing 50 health

@zompi2
Copy link
Contributor Author

zompi2 commented Dec 6, 2021

I had to remind myself what issue I had have in a first place, because it was some time ago.

I made a description unnecessary overcomplicated. The issue is actually more trivial. This is how it was:

  • I had a Character with AttributeSet
  • AttributeSet had a value called Health
  • Inside of ACharacter::BeginPlay() I was reading AttributeSet->GetHealth(); (in c++ - it's important)
  • Inside of the Editor I created a Character_BP from my Character and put it in the level.

And now the magic happens

  • Duplicate Character_BP (let's call it Character2_BP)
  • Put Character2_BP in the level
  • When game starts - there is a read access violation on FGameplayAttributeData::GetCurrentValue() when the GetHealth() in BeginPlay is called.

Making AttributeSet Transient fixes this crash.

I'm trying to figure out how to describe this in the document.

@tranek
Copy link
Owner

tranek commented Dec 7, 2021

That sounds like the duplicating BP Actor bug https://github.com/tranek/GASDocumentation#troubleshooting-duplicatingblueprintactors and the UE Issue https://issues.unrealengine.com/issue/UE-81109. Does that sound like what you're describing?

@zompi2
Copy link
Contributor Author

zompi2 commented Dec 7, 2021

Oh... It looks like this is it, actually. I haven't noticed this section for some reason. Ok, so the issue is already covered :D

Anyway, making AttributeSet Transient seems to fix the problem too. I haven't noticed any problems that could be caused by Transient in my project so far.

May I write about it in the section 9.4?

@SalahAdDin
Copy link

@zompi2 yes, please!

@zompi2
Copy link
Contributor Author

zompi2 commented Jun 8, 2023

Reviving the dead pull request :D

@tranek @SalahAdDin - I modified the notes that should better fit the document. I divided the 9.4 section into 9.4.1 and 9.4.2 where I present two possible workarounds for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants