Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Cant use Pointer for TArray

Im trying to create a TArray pointer to store a link to a const TArray reference outputed by a Reference Skeleton.

 // Fill out your copyright notice in the Description page of Project Settings.
 #pragma once
 #include "Components/ActorComponent.h"
 #include "SpriterSkeletonComponent.generated.h"
 UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
 class SPRITEREPICTEST_API USpriterSkeletonComponent : public UActorComponent
     // Sets default values for this component's properties
     // Called when the game starts
     virtual void BeginPlay() override;
     // Called every frame
     virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;
     UPROPERTY(BlueprintReadOnly) // ERROR: Inappropriate '*' on variable of type 'TArray', cannot have an exposed pointer to this type.
     TArray<FTransform>* BoneTransforms;
     TWeakObjectPtr<USkeletalMeshComponent> SkeleComponent;

Tried putting the "*" inside of the <> and i get the same Error. This is the code for obtaining the data.

 SkeleComponent = (USkeletalMeshComponent*)GetOwner()->GetComponentByClass(USkeletalMeshComponent::StaticClass());
 BoneTransforms = SkeleComponent->SkeletalMesh->RefSkeleton.GetRefBonePose(); // RETURNS: const TArray<FTransform>&
Product Version: UE Github Master branch
more ▼

asked Feb 12 '16 at 02:56 PM in C++ Programming

avatar image

100 14 18 25

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

TArray* are not a supported UPROPERTY type. The only way to do what you are trying to do is remove the UPROPERTY and do it without that support. It's kind of dangerous though since the object that it is pointing to can be garbage collected and you'd never know until you accessed it and crashed.

more ▼

answered Feb 12 '16 at 05:30 PM

avatar image

joeGraf STAFF
1.5k 35 12 69

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Blueprints don't support pointers of any type except UObject pointers (because they can only be used in pointers anyway). Because of that UHT don't know what to do with this varable and give you error, so remove BlueprintReadOnly, if that does not work remove UPROPERTY() all together and manually manage that pointer, null it when object it points to is deleted, i recommend you do that anyway because i'm not sure if TArray pointers would work properly in reflection system.

What you trying to do is quite unconventional (and probably not recommended) in UE4, i never seen case of TArray pointer in UE4 (and i seen a lot of UE4 code ;p). Common practice in UE4 for something like that is to create functions with reference argument to interact with forgain array and modify it, like GetAllActorsOfClass for example:


more ▼

answered Feb 12 '16 at 05:03 PM

avatar image

37.3k 936 172 1116

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question