yes I already changed it but no luck
look, I posted above some stuff,
I think I found the reason of the problem, I will update here if the problem reason is confirmed
You should ditch blue print native code and grab C++ as intented for unreal.
This way you will learn some things that are totally separete from blue prints that can only connect to blue prints if you expose values to them.
Const FVector WorldLocationVar = GetTransform().TransformPosition(Location);
To do this all you need is the location from the component so before the line above you need this.
const FVector Location = StaticMesh01->GetComponentLocation();
You still might get errors because you have the components made funnmy inside the constructor there is no uscene component there, you attach to it but you donât make the component and you donât have a mesh.
the problem is here, the actor is not spawned , and setting the mesh on the sub meshes in this actor returns the nullptr getting world transforms
.
I am spawning this way in code, but not sure if this is correct
.h
UPROPERTY(EditAnywhere, BlueprintReadWrite)
AItemGroup* ItemGroupRef;
.cpp
FTransform SpawnTransform;
SpawnTransform.SetLocation(OutRow->Location);
ItemGroupRef = GetWorld()->SpawnActor<AItemGroup>(ItemGroup, SpawnTransform, SpawnInfo);
Yep, get world needs some settings in the header file, two things if you are spawning in c++ you need two variables for it, one the object component and the other is a key refrence to the class object.
< AA list of actors or components >
and the object class.
There for you need a pointer to define the object class, this is a pointer class object. Then you need a "Tsubclass of " to state object class.
But as stated first you need to declare the class as the pointer and name it as the object you are going to use, then declare the tsubclass with the same class pointer you made and define there the name of the object class.
After you are done with it, you can use get world in your cpp with all these variables created in the header.
Itâs not a simple mechanism.
class object
APickupWeapon* NewWeaponItem = GetWorld()->SpawnActorDeferred<APickupWeapon>(PickupWeapon, SpawnLocation, nullptr, nullptr, ESpawnActorCollisionHandlingMethod::AlwaysSpawn);
if (IsValid(NewWeaponItem))
{
// adding items to the array
ItemObjects.Add(NewWeaponItem);
}
object component is accessed by ItemGroupRef
while spawning the actor group contains all the containers for the objects to be placed dynamically
So then you are accesing the object you are spawing from a bp library ?
no, pure C++
ItemGroupRef = GetWorld()->SpawnActor<AItemGroup>(ItemGroup, SpawnTransform, SpawnInfo);
Itâs made corractly with < AitemGroup > being the actor you are invoking from another cpp page or a blue print and the item Grup you made based on the object class.
AItemGroup
is just an independent C++ class holding 5 static meshes sub of AActor
APickupWeapon
is derived from the base pickup C++ class sub of APickupBase
still where is the object defined, you only have the AA class and the object of the cllass but I donât see no key object as in the object itâs self.
Look.
class AClassname* CurrentObjectyou are going to use
This is missing.
and then the subobject tclass.
< AClassname > ObjClass;
You mean objects array where i am adding spawn items?
I have 3 classes to be used
BasePickupClass | SubWeaponPickup
AActor | SubItemGroup
The object of the class is used in the get world sintax.
with < A class name >
But then you need the pointer you made first on the object of the class as the component itâs self.
So out of the class pointer you are going to get an object and out of the Tsubclass you are going to get a Object class that you can use in your get world sintax. But the object is defined with the pointer when you invoke it after get world line.
So there for you need to define a component you are going to use in your cpp that represents that class with itâs class object.
CurrentObject-> blah blah blah
I have no idea about bp, looks like a set function, if you generate code out of this you should post pointers. < I item group > is just the class name or actor name better put and most likeley the tsub class of < Actor >
So itâs not the pointer that makes the object component in your current cpp to use out of the foreign imported class with Tsubclass of
You donât have a component defined on the imported class to represent you in your current cpp. The component you are using is probally the component of the current C++ class you are in, not the imported one.
If I look at the code now I understand why you did not have a mesh, because you impoted it with Tsubclass from else where.
So you need to create a component for your imports out of another class.
You need an object component
Yep and itâs why you might want to part from it and use regular C++ api from unreal.
What do you see here
/** type of damage */
UPROPERTY(EditDefaultsOnly, Category=Damage)
UClass* DamageType;
Vs.
/** type of damage */
UPROPERTY(EditDefaultsOnly, Category=Damage)
TSubclassOf<UDamageType> DamageType;
In this case they named the component the same as the object class.
That is not my style, but itâs appliclable notice there are two things.
So you want two things.
Create pointer object to have as component.
Create a object class to specify inside the getworld in cpp.
But the pointer object will be used as component.
Really the GetWorld() all it does is tells what class to spawn, once the foreign object class is imported in your cpp you need the pointer from the class to create an object component for it.
blueprint cleaned
.h
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, meta=(DisplayName=âItem Group Refâ, Category=âDefaultâ, MultiLine=âtrueâ, OverrideNativeName=âItemGroupRefâ))
AItemGroup* ItemGroupRef;
.cpp
FTransform Location{};
FTransform MakeTransform_Return{};
AActor* AActor_Ref{};
AItemGroup* ItemGroup_Ref_Local{};
FTransform Location{};
FTransform MakeTransform_Return{};
AActor* AActor_Ref{};
AItemGroup* ItemGroup_Ref_Local{};
MakeTransform_Return = UKismetMathLibrary::MakeTransform(// vector, rotator, vector);
AActor_Ref = UGameplayStatics::BeginDeferredActorSpawnFromClass
(
this,
AItemGroup::StaticClass(),
MakeTransform_Return,
ESpawnActorCollisionHandlingMethod::Undefined,
((AActor*)nullptr)
);
MakeTransform_Return = UKismetMathLibrary::MakeTransform(// vector, rotator, vector);
ItemGroup_Ref_Local = CastChecked<AItemGroup>(UGameplayStatics::FinishSpawningActor
(
AActor_Ref,
MakeTransform_Return),
ECastCheckedType::NullAllowed
);
ItemGroupRef = ItemGroup_Ref_Local;