C++ and Blueprint, can't assign property

I can’t assign to a property in a Blueprint, it just keeps saying None.

The difference between this one that doesn’t seem to work and the ones that do, is it is a property of my own class type, which I then fill out in a blueprint and try to assign.

This is the property in my character.

UPROPERTY(EditDefaultsOnly, Category=LaserPointer, BlueprintReadWrite)
ALaserPointer* LaserAttractor;

Here’s my property class header:

UCLASS(placeable, Blueprintable)
class ALaserPointer : public AActor
{
	GENERATED_UCLASS_BODY()

	UPROPERTY(EditDefaultsOnly, Category=LaserPointer, BlueprintReadWrite)
	UParticleSystem* LaserDot;

	UPROPERTY(EditDefaultsOnly, Category=LaserPointer, BlueprintReadWrite)
	UParticleSystem* LaserSpark;

	UPROPERTY(EditDefaultsOnly,Category=LaserPointer, BlueprintReadWrite)
	USkeletalMesh* LaserBeam;

	UPROPERTY(EditDefaultsOnly,Category=LaserPointer, BlueprintReadWrite)
	APointLight* LaserLight;

};

“Are you trying to drag a blueprinted
version of ALaserPointer into the
default properties of a different
blueprint?”

If I’m following you, this is what you are trying to do.


Well I dont think you can do this because a BluePrint is a class, not an instance of a class.


Blueprints As Classes Vs World Object Instances

You cannot assign your Blueprint laserpointer to the ALaserPointer* because the blueprint is not an actual object.

A blueprint is exactly that, a blueprint, a plan, not a real world instance of the actor.

Blueprints are actually something new and awesome that our friends at Epic have created.

A blueprint is a class that is easier to operate on and change than going into the c++ code, if you set up all your properties in the .h file to be accessible from the editor.

The main advantage of blueprints as far as I am concerned is that you do not have to recompile your entire source code after changing blueprint properties!


But dont forget, blueprints are in fact classes, just more accessible/malleable classes :slight_smile:


This became obvious to me when I was learning to spawn instances of blueprints through the c++, you can do this because blueprints are classes!

:slight_smile:


My recommendation:

If this is all relative to your character, put the ALaserPointer on your character as a property as so:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=LaserPointer)
ALaserPointer* LaserAttractor;

In the event graph of your character BluePrint, you can spawn a new ALaserPointer from your LaserPointer Blueprinted class and assign it to LaserAttractor, during the construction of the character

If you have any issues finding the Spawn function, make sure to turn off the Context Sensitive checkmark in the right click menu.


This should get you going :slight_smile:

Rama

Thanks, this is getting me in the right direction.

I ran into trouble in the Blueprint Construction Scrript, it doesn’t have the SpawnActor node available, and in the event graph it doesn’t have the construction script available.

yea you’re right about that, I guess it does make sense to not be able to spawn stuff in another thing’s constructor :slight_smile:

Anyways

Here’s your answer!

Spawn Actor from BP at ReceivedbeingPlay in EventGraph!

Also another option would be to make a BP of the Actor class you made then in your character you need to have a variable of the actor you made and in the defaults you can set it to be your BP you made.

Best Regards,

Ryan

Hi Ryan, I think what you are saying was actually my initial problem.

I made a macro in the ConstructionScript and then in that am able to spawn. I think it doesn’t make any sense that while you can not use a spawn node in the Construction Script, that you can call a macro there that does use the Spawn node.

I have some logic bugs I need to get through before I can verify that this answer is indeed what is correct. So far spawning in the Event Graph appears to be the best way.

Dear Michael,

Further question: How exactly are you trying to assign this property? by dragging something into Blueprints’ defaults tab? or through blueprint code?

If you are trying to assign through blueprint or code, your issue is the “EditDefaultsOnly” part.

I cant imagine how you could be doing it any other way since you’d have to somehow drag an instanced actor from the world into the default properties of the BP since the property is of type Actor.


This might sound a little off-the-wall but please give it a go and let us know of any change to your situation

you have EditDefaultsOnly and BlueprintReadWrite set, which is a bit of a contradiction as far as I know, because blueprints should not be writing to a EditDefaultOnly property, as it should only be edited in its defaults.


I understand that the source classes work, but maybe this apparent contradiction is confusing the engine somehow

Please try one of these two setups and let me know if it changes the behavior

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=LaserPointer)
ALaserPointer* LaserAttractor;

or

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=LaserPointer)
ALaserPointer* LaserAttractor;

You probably want this:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=LaserPointer)
ALaserPointer* LaserAttractor;

:slight_smile:

Rama

Thanks for the answer, but that isn’t it, I tried it.

It’s something to do with, not being able to assign a blueprint of the ALaserPointer to the LaserAttractor property, it just has a red background when I try.

how exactly are you trying to assign

ALaserPointer* LaserAttractor

Are you trying to drag a blueprinted version of ALaserPointer into the default properties of a different blueprint?

I’m still not understanding why you are trying to assign an actor pointer in defaults rather than during runtime via blueprint graph or c++, can you explain the background for your question and what your overall goal is?

:slight_smile:

Rama

Yes, that is exactly what I want to do.

I thought the Blueprint was the better place to construct things. The Laser-pointer Actor is just a collection of a couple emitters, a mesh and a light. I wanted it assigned in the Blueprint so the Artist could change it around if he wants.

Maybe I still don’t understand what Blueprints are for.

Also, I intend to put things into the Blueprint graph that modify the emitter behaviors later.

Before, I was assigning things through the C++ constructors and I got feedback on this forum that the proper place to do that stuff was in the Blueprint.

Now, that I’m thinking about it, I could just add the properties that laser pointer actor has all into my character. I thought it would be better encapsulated if it was it’s own object. That would also mean if for some gameplay reason, wanted to bring more of them in could control them completely separate of the character but the Artist would only have to edit them in one place.

I posted a separate answer above that should get you going

:slight_smile:

Rama