I am having issues getting UTankTrack::TickComponent to actually Tick. Has something changed in most recent versions of Unreal? I’m currently on version 4.14.3 (using xCode).
I was also having the same issue on UTankAimingComponent::TickComponent in the previous lecture.
I spent a couple hours today trying to debug this myself and I am hitting a brick wall. I even copied the source code directly from the lecture verbatim, and have isolated it to this exact step…
TankTrack.h
#pragma once
#include "Components/StaticMeshComponent.h"
#include "TankTrack.generated.h"
/**
* TankTrack is used to set maximum driving force, and to apply forces to the tank
*/
UCLASS(meta=(BlueprintSpawnableComponent))
class BATTLETANK_API UTankTrack : public UStaticMeshComponent
{
GENERATED_BODY()
public:
// Sets a throttle between -1 and +1
UFUNCTION(BlueprintCallable, Category = "Input")
void SetThrottle (float Throttle);
// This is max force per track in Newtons
UPROPERTY(EditDefaultsOnly, Category = "Input")
float TrackMaxDrivingForce = 400000; // assume 40 ton tank and 1G acceleration
private:
UTankTrack();
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
};
TankTrack.cpp
#include "BattleTank.h"
#include "TankTrack.h"
UTankTrack::UTankTrack()
{
PrimaryComponentTick.bCanEverTick = true;
}
void UTankTrack::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
UE_LOG(LogTemp, Warning, TEXT("Track Ticking"));
}
void UTankTrack::SetThrottle(float Throttle)
{
auto ForceApplied = GetForwardVector() * Throttle * TrackMaxDrivingForce;
auto ForceLocation = GetComponentLocation();
auto TankRoot = Cast<UPrimitiveComponent>(GetOwner()->GetRootComponent());
TankRoot->AddForceAtLocation(ForceApplied, ForceLocation);
}
Does not tick, does not show log. Is anyone else having this problem? I’ve probably made an error somewhere that I cannot diagnose…
Thanks in advance!