Hello to all,
I use UE 4.7 and I have two files a .cpp and a .h:
in the .h:
/** called when something enters the sphere component */
UFUNCTION(BlueprintNativeEvent, Category = "Switch Functions")
virtual void OnOverlapBegin_Implementation(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
/** called when something leaves the sphere component */
UFUNCTION(BlueprintNativeEvent, Category = "Switch Functions")
virtual void OnOverlapEnd_Implementation(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
in the .cpp:
void ALightSwitchBoth::OnOverlapBegin_Implementation(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if (OtherActor && (OtherActor != this) && OtherComp)
{
ToggleLight();
}
}
void ALightSwitchBoth::OnOverlapEnd_Implementation(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
if (OtherActor && (OtherActor != this) && OtherComp)
{
ToggleLight();
}
}
And when I compile the project, I will get the errors:
1>------ Build started: Project: CPPCode, Configuration: Development_Editor x64 ------
1> Compiling game modules for hot reload
1> Parsing headers for CPPCodeEditor
1>D:/Unreal Projects/CPPCode/Source/CPPCode/LightSwitchBoth.h(28): error : In LightSwitchBoth: BlueprintNativeEvent functions must be non-virtual.
1>Error : Failed to generate code for CPPCodeEditor - error code: OtherCompilationError (2)
1> UnrealHeaderTool failed for target âCPPCodeEditorâ (platform: Win64, module info: D:\Unreal Projects\CPPCode\Intermediate\Build\Win64\CPPCodeEditor\Development\UnrealHeaderTool.manifest).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ââD:\Program Files\Epic Games\4.7\Engine\Build\BatchFiles\Build.batâ CPPCodeEditor Win64 Development âD:\Unreal Projects\CPPCode\CPPCode.uprojectâ -rocketâ exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
So can I use virtual functions or not with _implementation? What do I do wrong?