星鸿阁

 找回密码
 立即注册
搜索
热搜: 活动 交友 动画
查看: 2125|回复: 1

SpawnActor failed because Blueprint is not an actor class

[复制链接]

2254

主题

2764

帖子

9644

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9644
发表于 2021-3-23 20:23:57 | 显示全部楼层 |阅读模式

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.


Product Version: Not Selected

标签:c++blueprintspawn actor from classblueprint classspawnactor

更多 ▼

已提出 Sep 09 '14 在 2:32 AM

Daveoh
148 ● 14 ● 18 ● 108







1 解答:sort 最早投票 ▼
5

I've answered my own question via a related question on here (https://answers.unrealengine.com/questions/59674/how-to-spawn-actor-from-string-path-to-actor-bluep.html).

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

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




回复

使用道具 举报

2254

主题

2764

帖子

9644

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9644
 楼主| 发表于 2021-3-23 20:24:20 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|starfluidga

GMT+8, 2025-3-10 04:51 , Processed in 0.020038 second(s), 20 queries .

Made by Liga 星鸿阁

Copyright © 2020-2048, LigaStudio.

快速回复 返回顶部 返回列表