スポーンさせたアクターからイベントを受け取りたい

今回[alweiさんのサイト][1]を参考にイベントディスパッチャーの練習としてマリオのブロックを下からたたいたらキノコが出てきてそれを取るとパワーアップするあれを再現中です。

「取るとパワーアップするキノコ(以下キノコ)」と「下からたたくとキノコが出てくるボックス(以下ボックス)」とプレイヤーキャラクター(sidescrollercharacter)(以下キャラクター)で構成されており、「キノコ」と「ボックス」はできたのですが「ボックスから新しくスポーンさせたキノコ」からのイベントを受け取れずに詰まっています


296618-
↑ボックスのBP:跳ねる処理後にアクター「BPkinoko」をスポーンする

296620-
↑キノコのBP:オーバーラップしたらgetkinokoイベントをコールして自分をデストロイするだけのBP

↑キャラクターのBP:getkinokoイベントを受けてパワーアップ(ジャンプMAXカウントを10秒間増加させる)(この画像で指定されているBPkinokoはテスト用に置いた右側のキノコでスポーンされたものではないです)

問題はこの記事のやり方だとあらかじめエディタ内のキノコをキャラクターのブループリントのBPkinokoのデフォルトに指定しておけないと、ボックスからスポーンしたキノコがイベントをコールしてもキャラクター側でバインドできていないためそれを受け取ることができないことです。スポーンしたアクターをデフォルトに設定する方法か若しくは別の何かいい方法があれば教えて貰いたいです。またその他画像を見て何かアドバイスがあればそちらも歓迎です。よろしくお願いします。

Hi,
I’m communicating on a Google translate basis with you, so you may excuse if I didn’t understand your problem correctly.

It looks like you are working with the Evenet Dispatcher. I would suggest to work with Blueprint Interfaces, these don’t need any Type Casting. By creating a BP Interface you can create a generic communication path betweeen Actors.

In the Class Settings of your Pawn you can add the BP Interface, compile and add the Interface Event (wich would be your getkinko event right now). In the Mushroom you can call the event by message with the overlapping Actor. If the Actor doesn’t use the BP Interface or its event then nothing will happen, so it’s pretty safe in terms of error accumilation.

If you would like to go more safe for the Destroy event of your mushroom, you can add an output bool in the BP Interface Function, that would need to be set to true in your Pawn so the musroom knows it was successfully used. Be Aware that the adding of the output bool will make the BP Interface function appear in the functions panel of the Actor you added the Interface (your pawn in this case).

If you understand good enough english this tutorial should be clear enogh, otherwise the it might gives you the right hints: WTF Is? Blueprint Interface - YouTube

You can also make sure that the mushroom overlap event only gets triggered by your pawn by setting up a custom collsion setting in the Mesh component, so it overlaps only with Pawn collisions.

I’m still newbie and not learning about BP interface, I’ll check it out next.
thank you for your answer.

自分も初心者なので、最適な方法かわからないのですがお力になれれば幸いです。

296726-キャラクターbp.png

なるほどイベントをキノコ側ではなくキャラクター側のブループリントで作っておけばよかったんですね!これならどのキノコを採ったか指定しなくていいから解決ですね。ありがとうございました!