UTankTrack::TickComponent not ticking?

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!

In the editor, did you try removing the component and re-adding it?

Hi DanM, thanks for getting back to me.

I was going to try that, I saw it suggested in the discussion on a previous lecture (after I posted this) but it turns out that I didn’t actually need to… After banging my head against the wall repeatedly yesterday, this morning I sat down with a fresh dev environment, fired up the editor and xCode from scratch and all seems to be working now! Go figure… :slight_smile:

Thanks again!

Closing and re-opening the editor fixed this for me.

I can second that, had the same issue and was solved by restarting my editor.

I can third (?) that. I was banging my head against the wall thinking I’d done something wrong and all it took was a restart of the editor

3 Likes

Privacy & Terms