OnComponentBeginOverlap.AddDynamicは、関数テンプレートのインスタンスが引数リストに一致しないと言っていますか?

DualBall

cppファイルでの私の使用:

BoxComp->OnComponentBeginOverlap.AddDynamic(this, &AAICharacter::OnBoxOverlap);
BoxComp->OnComponentEndOverlap.AddDynamic(this, &AAICharacter::OnBoxEndOverlap);

次のエラーが発生しました:

cannot convert argument 2 from 'void (_cdecl AAICharacter::*)(AActor*,UPrimitiveComponent*,int32,bool,const FHitResult &)' to 'void (_cdecl AAICharacter::*)(UPrimitiveComponent*, AActor*,UPrimitiveComponent*,int32,bool,const FHitResult &)

関連する関数を含むヘッダーファイルは次のようになります。最小限の再現可能な例であると私が考えたものを作成するために、コードの一部が省略されています。専門知識の欠如に基づいて価値のあるものを省略した場合は、lmk:

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Engine/DataTable.h"
#include "Subtitle.h"
#include "Components/BoxComponent.h"
#include "Components/AudioComponent.h"
#include "AICharacter.generated.h"

/**
* The purpose of this class is to create a dummy AI for testing out the code for character interactions.
*/


UCLASS()
class GV_PROJECT_API AAICharacter : public ACharacter
{
GENERATED_BODY()

public:
// Sets default values for this character's properties
AAICharacter();

private:
UFUNCTION()
void OnBoxOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherIndex, bool bFromSweep, const FHitResult & SweepResult);

UFUNCTION()
void OnBoxEndOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherIndex)

protected:

/*If the player is inside this box component he will be able to initiate a conversation with the pawn*/
UPROPERTY(VisibleAnywhere)
UBoxComponent* BoxComp;

このエラーに精通している人はいますか? 

ジャミ

エラーはかなり自明です。

cannot convert argument 2 from 'void (_cdecl AAICharacter::*)(AActor*,UPrimitiveComponent*,int32,bool,const FHitResult &)' to 'void (_cdecl AAICharacter::*)(UPrimitiveComponent*, AActor*,UPrimitiveComponent*,int32,bool,const FHitResult &)

示された行の2番目の引数(so&AAICharacter::OnBoxOverlapおよび&AAICharacter::OnBoxEndOverlap)は、メッセージにリストされている最初の型を持っていますが、呼び出されている関数(AddDynamic())は2番目の型を予期しています。異なるタイプが問題にならない場合もありますが、この場合、一方から他方に変換する方法はありません。

私が見る唯一のトリックは、問題のタイプを比較した後です。物事がよりよく整列するようにスペースを挿入するのに役立ちます。

 void (_cdecl AAICharacter::*)(                      AActor*,UPrimitiveComponent*,int32,bool,const FHitResult &)
 void (_cdecl AAICharacter::*)(UPrimitiveComponent*, AActor*,UPrimitiveComponent*,int32,bool,const FHitResult &)

2つのメンバー関数は、予想よりも少ないパラメーターを取ります。これらの関数が使用されるのがこれだけの場合は、追加のUPrimitiveComponent*パラメーターを直接関数に追加できます。それ以外の場合は、必要な署名を持つラッパー関数を導入し、最初のパラメーターを無視して、メソッドを呼び出すことができます(一方のラッパーはを呼び出しOnBoxOverlap()、もう一方はを呼び出しますOnBoxEndOverlap())。例えば:

UFUNCTION()
void OnBoxOverlapWrapper(UPrimitiveComponent* /*ignored*/, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherIndex, bool bFromSweep, const FHitResult & SweepResult)
{
    OnBoxOverlap(OtherActor, OtherComp, OtherIndex, bFromSweep, SweepResult);
}

これには注意が必要です。無視しているパラメータの重要性を知っていますか?コードには、その最初のパラメーターを使用しないことに起因する、現在気づいていないバグが含まれている可能性があります。

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

TOP 一覧

  1. 1

    Python / SciPyのピーク検出アルゴリズム

  2. 2

    セレンのモデルダイアログからテキストを抽出するにはどうすればよいですか?

  3. 3

    tkinterウィンドウを閉じてもPythonプログラムが終了しない

  4. 4

    androidsoongビルドシステムによるネイティブコードカバレッジ

  5. 5

    ZScalerと証明書の問題により、Dockerを使用できません

  6. 6

    Reactでclsxを使用する方法

  7. 7

    VisualStudioコードの特異点/ドッカー画像でPythonインタープリターを使用するにはどうすればよいですか?

  8. 8

    二次導関数を数値計算するときの大きな誤差

  9. 9

    Ansibleで複数行のシェルスクリプトを実行する方法

  10. 10

    STSでループプロセス「クラスパス通知の送信」のループを停止する方法

  11. 11

    ビュー用にサイズ変更した後の画像の高さと幅を取得する方法

  12. 12

    Three.js indexed BufferGeometry vs. InstancedBufferGeometry

  13. 13

    __init__。pyファイルの整理中に循環インポートエラーが発生しました

  14. 14

    三項演算子良い練習の代わりとしてOptional.ofNullableを使用していますか?

  15. 15

    エンティティIDを含む@RequestBody属性をSpringの対応するエンティティに変換します

  16. 16

    Spring Boot Filter is not getting invoked if remove @component in fitler class

  17. 17

    値間の一致を見つける最も簡単な方法は何ですか

  18. 18

    reCAPTCHA-エラーコード:ユーザーの応答を検証するときの「missing-input-response」、「missing-input-secret」(POSTの詳細がない)

  19. 19

    Rパッケージ「AppliedPredictiveModeling」のインストール中にエラーが発生しました

  20. 20

    画像変更コードを実行してもボタンの画像が変更されない

  21. 21

    好き/愛の関係のためのデータベース設計

ホットタグ

アーカイブ