Child actor component にセットしたアクターへのcast方法

予めchild actor componentを追加していた場合は問題なくcastができるのですが、

BP内でadd child actor component関数で作成したものに対してcastが出来ず困っています。

例えば、次のようなアクターがあるとします。

・ビールケース

・ビール瓶

ビールケースはInt変数「NUM」の数だけ所定のロケーションにchild actor componentを生成し、

それぞれにset child actor class関数でビール瓶のアクタークラスをセットします。

ビール瓶はInt変数「INDEX」に応じて所定のマテリアルが適用されます。

このとき、ビールケースのアクターからビール瓶のINDEXを指定したいのですがcastができません。

何か回避方法などないでしょうか。よろしくお願いします。

I think what your looking to do is this :

You grab a reference of the child actor > Get child Actor > Then cast to the child actor, as shown above. As you can see i was able to get that “NUM” int you were talking about and also Call it’s function to set the int. You could also use “Interface’s” Well I hope this helps. :slight_smile:

Here’s what i said above:

子アクターの参照を取得します>子アクターを取得>次に、上記のように子アクターにキャストします。ご覧のとおり、私はあなたが話していた “NUM” intを取得することができましたし、intを設定する関数を呼び出すこともできます。あなたはまた "Interface"を使うこともできます。

I hope what i said is well translated, as i dont speak Japanese, so if it said something inappropriate blame google :slight_smile: がんばろう

Actually I was need to know about this situation:

(1)Add new “child actor component” to the actor somewhere in blueprint by using “Add Child Actor Component” function.

(2)Then set other actor to the component by using “Set Child Actor Class”.

(3)Then use “cast to (the actor object)”.

In above situation, I saw an error at the “cast to” node before.

However, I reproduce that situation into new actor to visual explain and I cannot see any error there now.

I don’t know why.

Anyway, thank you for your reply and I apologize my bad English.

Cool! And your English is just fine :slight_smile: Well the example i gave you actually worked when i tested it as far as casting, I see that your casting as pure And pure ive found works when your only getting a reference to a variable that isnt going to be modified at runtime ect., If you use a regualr cast all should be well. Im using version 4.21 of the engine. I personally prefer using Interfaces whenever possible. Well if i can help you with anything dont hesitate to ask. Friend and Good Luck!