code here:
void UTankTrack::SetThrottle(float Throttle)
{
auto ForceApplied = GetForwardVector() * Throttle * TrackMaxDrivingForce;
auto ForceLoc = GetComponentLocation();
UPrimitiveComponent* TankRoot = Cast<UPrimitiveComponent>(GetOwner()->GetRootComponent());
TankRoot->AddForceAtLocation(ForceApplied, ForceLoc);
void UTankMovementComponent::IntendMoveForward(float Throw)
{
UE_LOG(LogTemp, Warning, TEXT("Intend move forward throw: %f"), Throw);
LeftTrack->SetThrottle(Throw);
RightTrack->SetThrottle(Throw);
}
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class TTANKGAMEAGAIN_API UTankMovementComponent : public UNavMovementComponent
{
GENERATED_BODY()
private:
UFUNCTION(BlueprintCallable, Category = Input)
void IntendMoveForward(float Throw);
UFUNCTION(BlueprintCallable, Category = Setup)
void Initialise(UTankTrack* LeftTrackToSet, UTankTrack* RightTrackToSet);
UFUNCTION(BluePrintCallable, Category = Input)
void IntendTurnRight(float Throw);
UTankTrack* LeftTrack = nullptr;
UTankTrack* RightTrack = nullptr;
};
Crash Report:
Unhandled exception
UE4Editor_tTankGameAgain_9550!UTankTrack::SetThrottle() [C:\Users\winte\Documents\Unreal Projects\TonkGameUE4\tTankGameAgain\Source\tTankGameAgain\Private\TankTrack.cpp:13]
UE4Editor_tTankGameAgain_9550!UTankMovementComponent::IntendMoveForward() [C:\Users\winte\Documents\Unreal Projects\TonkGameUE4\tTankGameAgain\Source\tTankGameAgain\Private\TankMovementComponent.cpp:11]
UE4Editor_tTankGameAgain_9550!UTankMovementComponent::execIntendMoveForward() [C:\Users\winte\Documents\Unreal Projects\TonkGameUE4\tTankGameAgain\Source\tTankGameAgain\Public\TankMovementComponent.h:16]
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Core
UE4Editor_Core
UE4Editor_Core
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll
why is this happen`
im new to UE4.
Thanks for your adviŅe