So my question confuse me a few days;
I want to make some cars and they can move according to the roadmap.I read the tutorial https://docs.unrealengine.com/latest/INT/Videos/PLZlv_N0_O1gYup-gvJtMsgJqnEB_dGiM4/ and try to spawn cars like spawning batteris.It works but the car which I spawned can’t move.Then I set the car blueprint like this:
If I directly drag this blueprint to the level ,the car will move.But if I use the code like this:
if (WhatToSpawn != NULL)
{
// Check for a valid World:
UWorld* const World = GetWorld();
if (World)
{
// Set the spawn parameters
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = Instigator;
// Get a random location to spawn at
FVector SpawnLocation = GetRandomPointInVolume();
SpawnLocation.X += 2000.0f * i;
SpawnLocation.Z = 100.0f;
i++;
// Get a random rotation for the spawned item
FRotator SpawnRotation;
SpawnRotation.Yaw = 0;//FMath::FRand() * 360.0f;
SpawnRotation.Pitch = 0;// FMath::FRand() * 360.0f;
SpawnRotation.Roll = 0;// FMath::FRand() * 360.0f;
// spawn the pickup
AVtestPawn* const SpawnedPickup= World->SpawnActor<AVtestPawn>(WhatToSpawn, SpawnLocation, SpawnRotation, SpawnParams);
Vehicles.Push(SpawnedPickup);
//UE_LOG(LogTemp, Warning, TEXT("MyCharacter's Name is %d"), Vehicles.Num());
SpawnDelay = FMath::FRandRange(SpawnDelayRangeLow, SpawnDelayRangeHigh);
GetWorldTimerManager().SetTimer(SpawnTimer, this, &ASpawnVolume::SpawnPickup, SpawnDelay, false);
}
The spawned car then can’t move.Can anyone help me?