简体   繁体   English

如何在虚幻引擎 4 中投射对象引用?

[英]How to cast an Object Reference in Unreal Engine 4?

I want to reference an asset from another Blueprint to trigger an event from that.我想从另一个蓝图中引用一个资产来触发一个事件。

I have a variable with Object Reference type, and I set its default value to the particular asset I'm interested in.我有一个对象引用类型的变量,我将其默认值设置为我感兴趣的特定资产。

When it comes to action, I call a Cast node with the variable as an input, but the casting always fails.当涉及到操作时,我使用变量作为输入调用 Cast 节点,但转换总是失败。 I cannot understand it at all, because I thought that due to the default value it is already in the correct type.我完全无法理解,因为我认为由于默认值,它已经是正确的类型。

What am I doing wrong?我究竟做错了什么?

Here are some image of the problem:这是问题的一些图像:

在此处输入图片说明 在此处输入图片说明

The OnMessageReceived event is triggered correctly, then I see the second ("Unsuccessful cast...") message on screen. OnMessageReceived 事件被正确触发,然后我在屏幕上看到第二条(“Unsuccessful cast...”)消息。

unfortunately the context is not very clear.不幸的是,上下文不是很清楚。 but i don't think casting works in this case.但我认为在这种情况下铸造不起作用。 Try with:尝试:

One Item More items in Scene一个项目场景中的更多项目

Finally I have found the solution.最后我找到了解决方案。 The problem was not with the casting but with the place of setting it's default value.问题不在于铸造,而在于设置它的默认值的位置。

I moved that part to the level blueprint and now it is working.我将该部分移至关卡蓝图,现在它正在运行。

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

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