I want to create a Class With Combined AtmosphericFog, DirectionalLight and a SkyLight. And Everything must be editable via BluePrint. Its Possible?
I tryed acreating a actor class, but AtmosphericFog no “spawning”.
I want to create a Class With Combined AtmosphericFog, DirectionalLight and a SkyLight. And Everything must be editable via BluePrint. Its Possible?
I tryed acreating a actor class, but AtmosphericFog no “spawning”.
When you create an actor blueprint you can add all of those things you mention as components.
Thanks, but I want C++, not blueprint.
is correct, you can use child actor component to make single actor with multiple child actors as a components of that actor.
Components are core feature of engine so it not just in Blueprint but also C++ any anything else, they are building (more like extansions) blocks for actors, here docs describing it:
Can U Give me a little example to how Do this?
Im Trying to create a class extends AActor.
Inside, .h file, im declaring a property
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category=Atmosphere)
TSubobjectPtr<class UAtmosphericFogComponent> AtmosphericFogComponent;
Inside .cpp constructor, im doing this:
AtmosphericFogComponent = PCIP.CreateDefaultSubobject<UAtmosphericFogComponent>(this, "AtmosphericFogComponent");
AtmosphericFogComponent->bVisible = true;
AtmosphericFogComponent->RegisterComponent();
RootComponent = AtmosphericFogComponent;
AddComponent(FName("UAtmosphericFogComponent"), true, FTransform(FVector()), AtmosphericFogComponent);
But not working. When I compile, after place this class on world, the AtmosphericFog not doing anything.
Im using an AActor base class.
UCLASS()
class AWeather : public **AActor**
{
GENERATED_UCLASS_BODY()
/** point light component */
UPROPERTY(VisibleAnywhere, Category = "Weather")
TSubobjectPtr<UAtmosphericFogComponent> AtmosphericFogComponent;
};
Or you saying to me use this:
UCLASS()
class AWeather : public **UChildActorComponent**
{
GENERATED_UCLASS_BODY()
/** point light component */
UPROPERTY(VisibleAnywhere, Category = "Weather")
TSubobjectPtr<UAtmosphericFogComponent> AtmosphericFogComponent;
};
The error is simple… Im trying to add a COMPONENT (UAtmosphericFogComponent), but in reality, I need to add an (AAtmosphericFog).
Not working because if i try to add UAtmosphericFogComponent I will need to replicate the code of AAtmosphericFog. Look…
So instead to add a component I need to add an Actor. Is the same way?
Im trying this right now, but PCIP.CreateDefaultSubobject(this, TEXT(“AtmosphericFog”)); is working because AAtmosphericFog is an AActor and CreateDefaultSubobject expects to be a UObject.
But it place it? is UAtmosphericFogComponent is you child of UChildActorComponent, did you try use just UAtmosphericFogComponent?
No UAtmosphericFogComponent is good maybe set some values on it, maybe default properties make nothing
Then use UChaildActorComponent and place AAtmosphericFog in it or replicate that code
It’s ok it do that so it accepts all UObject, so whats wrong with that?
You need to do something with it before assigning to root component like
AtmosphericFogComponent->bVisible = true;
or dont assaign at all and leave it with AddComponent
btw, you can check component generation by making blueprint with AWeather as a parent, component made by parent should be there
You made it work?
Im cant create (add to root) if is derived from an AClass. Basicaly what i trying to do is this, but in C++.
This is the error:
cannot convert from ‘TSubobjectPtr’ to ‘USceneComponent *’
Thanks for helping. C++ is so diferent to C# (that i know it). Everthing is “static”.
I realy apreciated if this kind of stuff was like this:
Class AWeather : AActor {
public AAtmonsphericFog AtmosphericFog;
public AWeather () {
AtmosphericFog = new AAtmonsphericFog();
}
}
YEAH!!! I Just Extends AAtmosphericFog, and replicate some code.
Resuming: just what I was missing is AtmosphericFogComponent->InitResource();
Now I have tryed the first code (with AActor) and works Fine.