x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Implement Custom Actor Component

I created a custom UActorComponent call ArenaCharacterAttributes. The character of my game is called ArenaCharacter. I created the ArenaCharacterAttributes component because I didn't want the ArenaCharacter to become blotted with code, however I wanted all of the characters variables to be easily edited from within the editor.

What I have done so far is I added the code below to my ArenaCharacter.h file:

     UPROPERTY(EditDefaultsOnly, Category = Attributes)
     UArenaCharacterAttributes* CharacterAttributes;

Then in the ArenaCharacter.cpp file I initialized the component with the below code:

     CharacterAttributes = PCIP.CreateDefaultSubobject<UArenaCharacterAttributes>(this, TEXT("CharacterAttributes"));

This did the job of showing all the ArenaCharacterAttributes variables in the ArenaCharacter blueprint, under the CharacterAttributes component.

alt text

However when I edit the defaults of the CharacterAttributes in the editor, it doesn't apply to the CharacterAttributes C++ counterpart. How do I make it so when I edit the defaults in the editor, those changes also apply to the code?

Product Version: UE 4.7
Tags:
screenshot (8).png (677.7 kB)
more ▼

asked Jun 16 '15 at 12:25 AM in C++ Programming

avatar image

Janyx
492 66 64 211

avatar image Matthew J Jun 16 '15 at 07:37 PM

Hi Ky Mercer,

The reason this doesn't work in the way you're attempting is because the blueprint itself is a child of the C++ class. According to all of the code in the C++ class, this blueprint doesn't exist and none of those values you're setting have been set. What type of function calls are you attempting to make in code that use these values?

avatar image Janyx Jun 16 '15 at 07:45 PM

That's what I figured was happening. I am mainly calling getters and setters functions in the code.

I read about some changes made in 4.8 to Actor Components. Would upgrading the engine version solve this issue?

avatar image Matthew J Jun 16 '15 at 07:48 PM

I'm not 100% sure that it would, but you could try it risk free by downloading the engine and making a copy of your project before converting, in case anything goes wrong in the conversion process.

avatar image Janyx Jun 16 '15 at 08:17 PM

Unfortunately it appears that upgrading to 4.8 didn't solve it. I miss understood what the release notes were saying.

How then can I go about getting a reference to the blueprint and assign it to "CharacterAttributes" in my code?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I tried doing this myself without any issues at all, even the ones I mentioned so I apologize for that. The following is what I did to recreate this:

First I made two classes, an Actor and an Actor Component. I then gave a couple variables to the component and gave the Actor the component itself. After that, I set up a debug message to print out one of the variables from the component on tick which updates if I change the variable in the details panel of the blueprint instead of the code, as you were attempting to do. Here are a few pastebin links of all of the code files.

http://pastebin.com/8tKPdgNt http://pastebin.com/JK2tRVY1 http://pastebin.com/KXgqWAqb http://pastebin.com/HX6pPzSv

I hope this helps!

Matthew Clark

more ▼

answered Jun 18 '15 at 09:51 PM

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question