Carla: where is implemention of the function SpawnVehicle() in VehicleSpawnerBase.h?

Created on 5 Feb 2018  路  7Comments  路  Source: carla-simulator/carla

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.

question

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.

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jinfagang picture jinfagang  路  3Comments

kartikye picture kartikye  路  3Comments

qixiaoshuai0120 picture qixiaoshuai0120  路  3Comments

metaluga145 picture metaluga145  路  4Comments

hc167 picture hc167  路  4Comments