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"

Subclassed character won't tick

I have the following base class:

TOPPlayer.h

 UCLASS()
 class ATOPPlayer : public ACharacter
 {
     GENERATED_BODY()
 public:
     ATOPPlayer();
     virtual void Tick(float DeltaSeconds) override;
 };

TOPPlayer.cpp

 ATOPPlayer::ATOPPlayer()
 {
     PrimaryActorTick.bCanEverTick = true;
     PrimaryActorTick.bStartWithTickEnabled = true;
     PrimaryActorTick.bAllowTickOnDedicatedServer = true;
 }
 void ATOPPlayer::Tick(float DeltaTime)
 {
     if (GEngine) {
         GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Yellow, "Ticking (Base)!");
     }
     Super::Tick(DeltaTime);
 }


... And the following subclass:

TOPAvatarPlayer.h

 UCLASS()
 class ATOPAvatarPlayer : public ATOPPlayer
 {
     GENERATED_BODY()
 public:
     ATOPAvatarPlayer();
     virtual void Tick(float DeltaSeconds) override;
 };

TOPAvatarPlayer.cpp

 ATOPAvatarPlayer::ATOPAvatarPlayer()
 {
     //PrimaryActorTick.Target = this;
     PrimaryActorTick.bCanEverTick = true;
     PrimaryActorTick.bStartWithTickEnabled = true;
     PrimaryActorTick.bAllowTickOnDedicatedServer = true;
     //Super::PrimaryActorTick.AddPrerequisite(this, PrimaryActorTick);
 }

 void ATOPAvatarPlayer::Tick(float DeltaTime)
 {
     if (GEngine) {
         GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Yellow, "Ticking (Avatar)!");
     }
     Super::Tick(DeltaTime);
 }


My project uses two maps + two game modes. A main menu map set to use a "main menu" game mode, and a single-player map with an override set in the world settings to use a "single-player" game mode. The main menu game mode uses the ATOPPlayer pawn class, while the single-player mode uses the ATOPAvatarPlayer pawn class...

When the "main menu" map loads, I successfully see the words "Ticking (Base)!" appear in yellow... but as soon as I click the start button, the "single-player" map gets loaded, but I don't see "Ticking (Avatar)!" OR "Ticking (Base)!" appear on the screen at all. I've tried everything I could find via google, yet to no avail.

Anyone have any idea what could cause this to occur, and what I can do to fix it?

Product Version: UE 4.11
Tags:
more ▼

asked May 26 '16 at 10:57 AM in C++ Programming

avatar image

MichaelWion
245 23 39 49

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

1 answer: sort voted first

Right... Well to anybody who comes across this issue, this was resolved by adding the following to BeginPlay() on the subclassed character:

 /* It's dirty... but hey, it works! */
 auto level = GetWorld()->GetLevel(0);
 this->PrimaryActorTick.Target = this;
 this->PrimaryActorTick.RegisterTickFunction(level);

  
 

If anybody could clarify why this was even necessary, I'd very much appreciate it. Thanks!

more ▼

answered May 26 '16 at 11:32 AM

avatar image

MichaelWion
245 23 39 49

avatar image MichaelWion Jun 07 '16 at 10:24 AM

Right, so on second thought, this did in fact fix my character class... But it doesn't appear to be working when I subclass APlayerStart. So I no longer have any idea what is wrong. It's like some actor classes have no problem with simply overriding Tick and adding PrimaryActorTick.bStartWithTickEnabled = true;, whereas certain other actor classes have various other needs.

I'd very much like to be enlightened about this issue!

(comments are locked)
10|2000 characters needed characters left
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