简体   繁体   English

虚幻引擎4强制转换为父类失败

[英]Unreal Engine 4 Cast to parent Class Fails

I want to Cast a Child to his Base Class. 我想让一个孩子加入他的基础班。

I have a Class called Road_Empty and a child Class Road_Left. 我有一个名为Road_Empty的班级,还有一个子类Road_Left。

Iam using this flow to spawn a Random Road Tile. Iam使用此流生成随机Road Tile。

Flow

This should run smoothly. 这应该运行顺利。 But the Cast fails evertime. 但是演员表总是失败的。

What is wrong there? 那里怎么了

Though you've found that the reason is Classes are filled with wrong types, I'd like to provide some more information: 尽管您发现原因是类填充了错误的类型,但我想提供更多信息:

  1. You don't have to cast child classes objects to parent class object, since they can be used directly as parent class object. 您不必将子类对象强制转换为父类对象,因为它们可以直接用作父类对象。

  2. If your spawning failed so it returns None , the cast can also failed. 如果生成失败,因此返回None ,则转换也可能失败。 The most common failure is because of collision handling, but in your case of Always Spawn, Ignore Collisions then it can hardly fails. 最常见的故障是由于冲突处理造成的,但是对于“ Always Spawn, Ignore Collisions产生”( Always Spawn, Ignore Collisions则几乎不会发生故障。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM