C++: Spawn and move vehicles (controller->car)

Hello,
i try to set up a controller → car set up, so that I can control every car in every frame with the controller.
My car is driving when it is placed without the controller.
It also works for a moving cube(with the controller), but not for cars. I do not get what I’m doing wrong.

This is part of my .h of the controller:

std::vector<AMyPawn*> car_vector;
UPROPERTY(EditAnywhere, Category = "Spawned Car")
TSubclassOf<AMyPawn> TSubClass_SpawnedCar;

This is the controller .cpp part in the “begin” function:

   AMyPawn* obj = GetWorld()->SpawnActor<AMyPawn>(TSubClass_SpawnedCar,our_loc,FRotator::ZeroRotator);
   car_vector.push_back(obj);

The car spawns and looks correct.
Every tick I’d like to control its movemnt:

for(std::vector<AMyPawn*>::iterator it = car_vector.begin(); it != car_vector.end(); it++)
    {
        FVector loc = (*it)->GetActorLocation();
        FString d_string = loc.ToString();
        UE_LOG(LogTemp,Log,TEXT("Car %i at position: %s"),counter,*d_string);

         //Calculate movement for vehicle
        (*it)->MoveForward(1.0f);
    }

MoveForward is declared in the car’s cpp:

void AMyPawn::MoveForward(float Val)
{
    UE_LOG(LogTemp,Log,TEXT("Throttle input set to: %f"),Val);
    GetVehicleMovementComponent()->SetThrottleInput(Val);
}

Everything works until here - the ThrolleInput is set to 1 - but the car does not move. It applies possible physics (drops from the air to the ground) but does not move. What am I doing wrong?

Im glad for any help!
thanks a lot!

Hi, SetThrottleInput will only work with an actor with a controller, you need to either create a controller for each car or move them directly.

Hi, im sorry I do not really understand that - it did not even work just for one car. I can put the moveForward function in the tick of the car-class aswell and nothing happens. what do you mean with move them directly? any specific function? im pretty new trying to understand this problem.
anyway, thanks for your response:)

SetThrottleInput works with APlayerController. For testing, create 1 car and do posses in a controller. Then you should be able to move your car.

Ok ill test it in 10h from now.
So I change my Acotor (Controller now) to a APlayerController and try Posses the car? Ill give it a try then… hope it works

This thread might help: Cannot create vehicle... UpdatedComponent has not initialized its rigid body actor - Character & Animation - Unreal Engine Forums