Hello,
I'm currently reading your awesome code but I find something very confusing that in VehicleSpawnerBase.h, there's a SpawnVehicle() which I can't find the implemention.
Where's it?
Thank you.
Hi @barontxu, good catch ;) the function is implemented in the derived _"VehicleSpawner"_ Blueprint; note that it is marked as UFUNCTION(BlueprintImplementableEvent). When you call this function you are triggering a blueprint event.
The C++ code decides when and where the vehicle is spawned, but the Blueprint decides the model and color of the vehicle. This way the C++ code doesn't need to know about the assets.
@nsubiron Yes i see. Do we have to spawn actor in blueprint? I tried c++, but the car i spawned just can't move.
@nsubiron And thanks much to your swiftly respond. You're so nice.
It should work in C++ too. Just make sure the vehicle is a subclass of ACarlaWheeledVehicle and follow all the steps in AVehicleSpawnerBase::SpawnVehicleAtSpawnPoint() function (you need to spawn the controller and give it a road map).
@nsubiron you mean, for example, I can do it with
GetWorld()->SpawnActor
Yes, that should work
Thank you. I'll give it a try.
Most helpful comment
Hi @barontxu, good catch ;) the function is implemented in the derived _"VehicleSpawner"_ Blueprint; note that it is marked as
UFUNCTION(BlueprintImplementableEvent). When you call this function you are triggering a blueprint event.The C++ code decides when and where the vehicle is spawned, but the Blueprint decides the model and color of the vehicle. This way the C++ code doesn't need to know about the assets.