Trying to run a function from a line trace gives an error.
So I'm not new to c++ programming, but I am new to c++ in unreal. I wanted to make an "Interactable" class, and how it's meant to work is when a line trace that's activated by a keypress hits it, it runs an event that can be used in blueprints to make implementation easier. I started making this using the c++ fps template. My "Interact" function is located on the character's .cpp file. I used
The ButtonPressed() Function/Event is labeled as
in my The problem is that when I try and compile this, I get these errors:
1: Interactable.gen.cpp.obj : error LNK2005: "public: void __cdecl AInteractable::ButtonPressed(void)" (?ButtonPressed@AInteractable@@QEAAXXZ) already defined in Interactable.cpp.obj
2: Interactable.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AInteractable::ButtonPressed_Implementation(void)" (?ButtonPressed_Implementation@AInteractable@@UEAAXXZ)
3: Interactable.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl AInteractable::ButtonPressed_Implementation(void)" (?ButtonPressed_Implementation@AInteractable@@UEAAXXZ)
4: A:\Users\######\Documents\Unreal Projects\TestingGrounds\Binaries\Win64\UE4Editor-TestingGrounds-0289.dll : fatal error LNK1120: 1 unresolved externals
(I censored my windows user.)
Could anyone help me out?
Is your button pressed function marked as a BlueprintNativeEvent in its UFUNCTION tag? If so, you'll need to call your function ButtonPressed_Implementation instead of ButtonPressed.
answered Jun 07 '19 at 03:10 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here