Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //In your controller's header file:
- private:
- DECLARE_DELEGATE_OneParam(MyAwesomeDelegate, FVector)
- /** The actual delegate declaration */
- MyAwesomeDelegate MyAwesomeDelegateExecFunc;
- public:
- /** Binds a UFUNCTION
- * @param InUserObject - the object that contains the UFUNCTION
- * @param FuncName - the name of the UFUNCTION (return type: void, parameter: FVector)
- */
- void BindAwesomeDelegateExecutionFunction(UObject* InUserObject, FName FuncName);
- //In your controller's source file:
- void AMyPlayerController::BindAwesomeDelegateExecutionFunction(UObject* InUserObject, FName FuncName)
- {
- MyAwesomeDelegateExecFunc.BindUFunction(InUserObject, FuncName);
- }
- //to call the function that is binded to your delegate, somewhere inside your controller's source file type:
- MyAwesomeDelegateExecFunc.Execute(AVectorValue);
- //----------------------------------------------------------------------------------//
- //Character's header file:
- private:
- UFUNCTION()
- ExecutionFunction(FVector AVectorParam);
- //Somewhere inside your character's source file (make sure to include your controller's header file):
- AMyPlayerController* Con=Cast<AMyPlayerController>(GetController());
- Con->BindAwesomeDelegateExecutionFunction(this,FName("ExecutionFunction"));
- //rest of your logic...
- void AMyCharacter::ExecutionFunction(FVector AVectorParam)
- {
- //the logic that gets executed
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement