Calling the correct constructor when creating a NewObject

Hi everyone! I’m new to UE4 C++ programming and I’ve seen that the new c++ operator shouldn’t be used. If I’m not wrong I should be using the NewObject function or StaticConstructObject. For now I’m using NewObject. The problem that I’m having is that in the object I want to create, I have a constructor with 4 parameters, and it seems like that with the NewObject function, I can’t access it. My question is: How can I access this constructor?

My code:

302915-codequestion.jpg

Constructor I want to call:

I do not think that this is “the unreal way” of doing things.
You can use custom constructors for UObjects and create them with “new” operator. I’m not sure if this is possible with actors.

If you want to setup custom parameters for actor before you spawn it - it’s better to use deferred spawn instead of “new” operator (at least for Actors)
Check this example:

	AActor* DefSpawn = UGameplayStatics::BeginDeferredActorSpawnFromClass(this, AShooterWeapon::StaticClass(), GetTransform(), ESpawnActorCollisionHandlingMethod::AlwaysSpawn);
	// setup params for def spawn
	// DefSpawn->Velocity = 300;
	// DefSpawn->Damage = 500;
	UGameplayStatics::FinishSpawningActor(DefSpawn, GetTransform());