SpawnActor failed because Blueprint is not an actor class

I’m receiving this error and cannot find any information on it so I thought I should ask about it on here, for my benefit and others’. This is the code I’m using to spawn an actor from a blueprint which I have assigned in the editor.

UBlueprint* VehicleBlueprint; // Assigned in the editor.
...
GetWorld()->SpawnActor(VehicleBlueprint->StaticClass());

The error I get is ‘SpawnActor failed because Blueprint is not an actor class’. Can anyone let me know what I’m doing wrong? Thanks.

I’ve answered my own question via a related question on here (How to spawn Actor from string path to Actor Blueprint? - Blueprint - Unreal Engine Forums).

Instead of using StaticClass() function on the UBlueprint, use the GeneratedClass member, i.e.

GetWorld()->SpawnActor(VehicleBlueprint->GeneratedClass);