Initiallizing the variables of a structure

I have a structure

USTRUCT()
struct FIgnoreActor
{
	GENERATED_USTRUCT_BODY()

	AActor* IgnoredActor;

	int16 TimeIgnored;

	FIgnoreActor()
	{
		IgnoredActor = NULL;
		TimeIgnored = 0;
	}
};

When I create a new structure of the array, I want to initialize it in the following way.

FIgnoreActor TempStruct = FignoreActor(Actorxyp, 10);

But I am unable to do it. I can do it in this method now though

		FIgnoreActor TempStruct;
		TempStruct.IgnoredActor = OtherActor;
		TempStruct.TimeIgnored = TimeRemoval;

But i want to do it using FignoreActor(

How about:

FIgnoreActor TempStruct = {Actorxyp, 10};

Isn’t that the normal way to initialize a struct in c++?

Here you go add this in your struct.

FIgnoreActor(AActor* OtherActor, int16 TimeRemoval)
 {
 	IgnoredActor = OtherActor;
 	TimeIgnored = TimeRemoval;
 }

Yup but I think that method doesn’t work in UE.

This would be the proper way to do “constructors”, vs “initializer lists” below. Please add a UPROPERTY() above your actor pointer usage otherwise the object will be garbage collected shortly after it is instantiated.

Also, your example uses a version of your code created in stack memory rather than heap memory. It won’t last long, so you either need this to be a member variable of some other class (also with UPROPERTY) or it needs to be allocated with the new operator.

Ok I will add an UPROPERTY() on top.

The structure is initialized above a class declaration. Something I read in this tutorial.
I don’t know if its the correct way to do it or now.