Car doesn't follwo spline

I’m pretty much new to Unreal Engine, I’m using Unreal 5.3 and I have the following code in my AI_Car class for it to follow a given spline:

include “AI_Car.h”

include <Kismet/GameplayStatics.h>

include <Kismet/KismetMathLibrary.h>

include “ChaosWheeledVehicleMovementComponent.h”

include <Components/SplineComponent.h>

float AAI_Car::GetPath() { USplineComponent* Spline = ActivePath->GetComponentByClass(); FVector ActorLocation = GetActorLocation(); FVector NextLocation = (Spline->FindTangentClosestToWorldLocation(ActorLocation, ESplineCoordinateSpace::World).Normalize(0.0001f) * FVector(200,200,200)) + ActorLocation; FRotator FinalRotation = UKismetMathLibrary::NormalizedDeltaRotator(UKismetMathLibrary::FindLookAtRotation(ActorLocation, Spline->FindLocationClosestToWorldLocation(NextLocation, ESplineCoordinateSpace::World)), GetActorRotation());

return UKismetMathLibrary::MapRangeClamped(FinalRotation.Yaw, -90.0f, 90.0f, -1.0f, 1.0f); }

void AAI_Car::BeginPlay() { Super::BeginPlay();

GetVehicleMovement()->SetUseAutomaticGears(false); GetVehicleMovement()->SetTargetGear(1, true); GetVehicleMovement()->SetThrottleInput(MaxThrottleInput); CurrentThrottleInput = GetVehicleMovement()->GetThrottleInput(); }

void AAI_Car::Tick(float DeltaTime) { Super::Tick(DeltaTime);

GetVehicleMovement()->SetSteeringInput(GetPath()); CurrentThrottleInput = GetVehicleMovement()->GetThrottleInput(); }

I used this video as reference (https://www.youtube.com/watch?v=AlMPqZ2d4BQ) and did the same functions as the blueprint the video showed, but for some reason the car suddenly decides to not follow the spline anymore, and some other times it just doesn’t follow it at all, just starts turning and spinning in a circle. I tried doing it in the blueprint like the video and it worked perfectly. What might the problem be? I’ll try and post some video evidence on this