I have added a virtual function to AActor, why can't i compile?

This is definitely the way to go.

But to refer to your errors, you’ve got linker errors because you didn’t provide an implementation. You can write in the header file e.g. virtual void Hit() {} to provide a empty one. But like Colorado said, just don’t edit the Actor class.

Create a new base class



Actor
   |
   v Unit (your class with the hit function
   |
   v Your classes which should inherit the hit function