knightster
(knightster)
January 14, 2016, 9:32pm
1
Hi,
I adapt the PowerUp tutorial to my need.
I drop a C++ actor directly on my level (I don’t use the Blueprint currently) and I add to the actor a box component to check overlapping actors
UE_LOG(LogClass, Log, TEXT("Create pickable area"));
PickableArea = CreateDefaultSubobject<UBoxComponent>(TEXT("PickableArea"));
PickableArea->AttachTo(RootComponent);
FVector boxInitSize(50.f, 90.f, 100.f);
PickableArea->SetBoxExtent(boxInitSize);
PickableArea is correctly initialized inside the constructor.
When I press the key to my action
void AHandballPlayerActor::PickTheBall()
{
if (PickableArea != NULL) {
dosomething
} else {
UE_LOG(LogClass, Log, TEXT("Invalid pickable area")
}
}
I always go in the else code. The PickupArea becomes NULL and I don’t use any code that assing PickableArea to NULL.
The other actor components are not null (1 SpringArm and 1 Camera).
Any tips?
Thanks
PS: do you provide the Blueprint/Level data for the PowerUp tutorial?
knightster
(knightster)
January 14, 2016, 9:43pm
2
I did to check anything. PickableArea is not NULL at the end of the constructor.
The constructor is called 3 times when the editor starts.
Can you set a data breakpoint on the PickableArea variable after it gets initialized?
https://msdn.microsoft.com/en-us/library/350dyxd0(v=vs.90).aspx
Right…but if you use a Data Breakpoint (different than normal breakpoint…see link above) the breakpoint will trigger when the variable changes it’s data. So, if you manage to set the data breakpoint after the constructor, you’ll see where it’s getting set to NULL.
What is the exact line that is setting the value to NULL inside that function?
Also, can you post the line where you declare PickableArea.? I assume it’s in the header for your class.
hmmm…unfortunately, that throws me past my current knowledge of the engine. not familiar enough with those functions.
knightster
(knightster)
January 14, 2016, 10:08pm
8
DataBreakpoint give
void FObjectInitializer::InitProperties(UObject* Obj, UClass* DefaultsClass, UObject* DefaultData, bool bCopyTransientsFromClassDefaults)
when copy element from editor into game object if I understand what is the purpose of UEditorEngine::PlayInEditor and CreatePIEWorldByDuplication
knightster
(knightster)
January 14, 2016, 10:13pm
9
That’s the line 2551. It called CopyCompleteValue that is part of the vcruntime.
knightster
(knightster)
January 14, 2016, 10:14pm
10
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = “Handball”, Meta = (BlueprintProtected = “true”))
UBoxComponent* PickableArea;
// Accessor to the actor box pick
FORCEINLINE class UBoxComponent* GetPickableArea() const { return PickableArea; }
knightster
(knightster)
January 14, 2016, 10:28pm
11
Ok I change the BlueprintReadWrite to BlueprintReadOnly and now it’s still reset to NULL but later
> UE4Editor-CoreUObject.dll!UObjectProperty::SetObjectPropertyValue(void * PropertyValueAddress, UObject * Value) Line 66 C++
UE4Editor-CoreUObject.dll!UObjectProperty::SerializeItem(FArchive & Ar, void * Value, const void * Defaults) Line 38 C++
UE4Editor-CoreUObject.dll!FPropertyTag::SerializeTaggedProperty(FArchive & Ar, UProperty * Property, unsigned char * Value, unsigned char * Defaults) Line 145 C++
UE4Editor-CoreUObject.dll!UStruct::SerializeTaggedProperties(FArchive & Ar, unsigned char * Data, UStruct * DefaultsStruct, unsigned char * Defaults, const UObject * BreakRecursionIfFullyLoad) Line 1320 C++
UE4Editor-CoreUObject.dll!UObject::SerializeScriptProperties(FArchive & Ar) Line 982 C++
UE4Editor-CoreUObject.dll!UObject::Serialize(FArchive & Ar) Line 926 C++
UE4Editor-CoreUObject.dll!StaticDuplicateObjectEx(FObjectDuplicationParameters & Parameters) Line 1655 C++
UE4Editor-CoreUObject.dll!StaticDuplicateObject(const UObject * SourceObject, UObject * DestOuter, const wchar_t * DestName, EObjectFlags FlagMask, UClass * DestClass, EDuplicateForPie DuplicateForPIE) Line 1553 C++
UE4Editor-UnrealEd.dll!UEditorEngine::CreatePIEWorldByDuplication(FWorldContext & WorldContext, UWorld * InWorld, FString & PlayWorldMapName) Line 3456 C++
UE4Editor-Engine.dll!UGameInstance::InitializePIE(bool bAnyBlueprintErrors, int PIEInstance) Line 150 C++
UE4Editor-UnrealEd.dll!UEditorEngine::CreatePIEGameInstance(int PIEInstance, bool bInSimulateInEditor, bool bAnyBlueprintErrors, bool bStartInSpectatorMode, bool bRunAsDedicated, float PIEStartTime) Line 2676 C++
knightster
(knightster)
January 17, 2016, 10:59am
12
I answer my question by removing the c++ actor from the level.
After I inherit a BP actor from my c++ actor, I was able to use the Pickable area.
Don’t know why it is not possible to use the c++ actor. So fixed by using a BP class.