Announcement

Collapse
No announcement yet.

ASkeletalMeshActor doesn't Tick

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    ASkeletalMeshActor doesn't Tick

    Hi,
    I posted this question yesterday in the AnswerHub, but it didn't get any attention and now it's already gone so deep in the list that it won't get any more attention. But I'm still stuck with that problem! I could use some help or advice on this.

    I created a C++ class based on ASkeletalMeshActor, called MySkeletalMeshActor. I then created a BluePrint based on this C++, called MySkeletalMeshActor_BP

    In the C++ class, I have overridden the BeginPlay and Tick methods, without forgetting to call Super:: for each of these methods. For the moment, these methods are only supposed to log a message, allowing me to check everything is fine.

    Result
    Only the BeginPlay() log is visible in the console. The Tick() method doesn't do anything.

    MySkeletalMeshActor.h
    Code:
    1. #pragma once
    2. #include "CoreMinimal.h"
    3. #include "Animation/SkeletalMeshActor.h"
    4. #include "MySkeletalMeshActor.generated.h"
    5. UCLASS()
    6. class UNNAMED_API AMySkeletalMeshActor : public ASkeletalMeshActor
    7. {
    8. GENERATED_BODY()
    9. protected:
    10. // Called when the game starts
    11. virtual void BeginPlay() override;
    12. virtual void Tick(float DeltaTime) override;
    13. };
    MySkeletalMeshActor.cpp
    Code:
    1. #include "MySkeletalMeshActor.h"
    2. void AMySkeletalMeshActor::BeginPlay()
    3. {
    4. Super::BeginPlay();
    5. UE_LOG(LogTemp, Warning, TEXT("Begin Play"));
    6. }
    7. void AMySkeletalMeshActor::Tick(float DeltaTime)
    8. {
    9. Super::Tick(DeltaTime);
    10. UE_LOG(LogTemp, Warning, TEXT("Tick"));
    11. }
    In the BluePrint, Tick is enabled:
    Click image for larger version

Name:	bp.png
Views:	1
Size:	142.2 KB
ID:	1573322

    Anybody knows what is wrong with SkeletalMeshActor Tick() method ?

    Thak you!

    #2
    Try these in the constructor:

    Code:
     // set this actor to call Tick() every frame
     PrimaryActorTick.bCanEverTick = true;
     PrimaryActorTick.bStartWithTickEnabled = true;

    Comment


      #3
      Thank for your suggestion. That works!
      Actually, only the line PrimaryActorTick.bCanEverTick = true; was enough.

      So, for those who could encounter the same problem, the full solution requires to overload the constructor, since the generated code for ASkeletalMeshActor doesn't include the constructor.

      Thus, in MySkeletalMeshActor.h I added this:
      Code:
      public:
          AMySkeletalMeshActor();
      And in MySkeletalMeshActor.cpp I added this:
      Code:
      AMySkeletalMeshActor::AMySkeletalMeshActor() 
      {
          PrimaryActorTick.bCanEverTick = true;
      }
      And everything works perfectly!
      ​​​​​​​Thanks again!

      Comment

      Working...
      X