x

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"

SpawnActor with Template does not Tick

If i use :

 AFloatingMyActor* ClonedActor = this->GetWorld()->SpawnActor(CurrentActor->GetActorLocation(), FRotator::ZeroRotator);
 //Not shown, Here i add a SceneComponent as RootComponent of ClonedActor a cube
 ClonedActor->SetActorLocation(CurrentActor->GetActorLocation() + FVector(0, -100, 0));

Then ClonedActor has it's BeginPlay() method called and it's Tick( float DeltaTime ) called at some interval. That's fine and my cloned actor floats just like any AFloatingMyActor created by hand in the "world outliner".

Now if i want to use a template actor with the FActorSpawnParameters structure in order to recover all the values in the UPROPERTYs of a AFloatingMyActor created by hand in the "world outliner" which reference is called CurrentActor:

 FActorSpawnParameters p;
 p.Template = CurrentActor; //an instance of AFloatingMyActor
 p.bNoCollisionFail = true;
 p.Name = TEXT("TEST");
 p.Owner = CurrentActor->GetOwner(); //resolves to NULL
 AFloatingMyActor* ClonedActor = this->GetWorld()->SpawnActor(CurrentActor->GetActorLocation(), FRotator::ZeroRotator, p);
 //Not shown, Here i add a SceneComponent as RootComponent of ClonedActor a cube
 ClonedActor->SetActorLocation(CurrentActor->GetActorLocation() + FVector(0, -100, 0));

Then ClonedActor has it's BeginPlay() method called and it's Tick( float DeltaTime ) is never called !!! ClonedActor->CanEverTick(); // resolves to false even though the constructor of AFloatingMyActor contains PrimaryActorTick.bCanEverTick = true; That's my main problem actually while i try to learn UE4.

I try to clone actors with C++ because our teacher said we better learn UE4 via C++ and looks like there's no way in UE4 to make C++ actor Asset.

Bonus oddity that would be cool to sort out :

Strangely i have to position the ClonedActor at CurrentActor->GetActorLocation() because the template actor gets moved to the position of the spawned actor. Then if i want my template actor to not move i have to put my clone at template position. The documentation says that the FVector passed to SpawnActor is the position of the spawned actor, not that the template actor gets moved too !! And it does that anyway.

Thanks for help.

Product Version: Not Selected
Tags:
more ▼

asked May 11 '15 at 01:48 PM in C++ Programming

avatar image

BoB_Xygene
1 1 1

avatar image BoB_Xygene May 11 '15 at 01:50 PM

Sorry for double post, i got an internal error and re-clicked the post button as i though post was not published.

avatar image BoB_Xygene May 11 '15 at 01:54 PM

Looks like the website stripped the [AFloatingMyActor] following each SpawnActor call !! I use [] because standard template marker are stripped...

avatar image BoB_Xygene May 11 '15 at 02:03 PM

Note that i do that in : void AQuickStartGameMode::BeginPlay() { //previous code goes here }

avatar image Aiko Creative Vision May 12 '15 at 09:16 AM

Hi !

We're facing the same problem. Did you find any solution ?

avatar image BoB_Xygene May 12 '15 at 06:01 PM

Hi, No sir.

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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