mklabs / ue4-targetsystemplugin

Dark Souls inspired Camera Lock On / Targeting system plugin

Home Page:https://www.unrealengine.com/marketplace/target-system-component-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Includes in .h files can be replaced with forward declarations in most cases

josator opened this issue · comments

commented

Normally it is better to avoid as many includes as posible in a .h file.

It is better to use a forward declaration instead a .h include in the header file, and then include the .h removed from the header in the .cpp file. for example in the TargetSystemComponent.h file you can remove

#include "GameFramework/PlayerController.h"

and replace it with

class APlayerController;

Then in TargetSystemComponent.cpp you will need to add

#include "GameFramework/PlayerController.h"

https://www.geeksforgeeks.org/what-are-forward-declarations-in-c/

bear in mind that forward declarations are not always possible, but for most cases, ie a pointer variable are enough and improve compilation times by reducing header dependencies.

Hey @josator thanks for the tip!

I'll keep this in mind when I'll work on the next batch of updates for this plugin. Meanwhile, if you feel like you can improve the code and have the time to do so, please feel free to fork and send a PR, I'll be happy to merge it in.

commented

Once I finish watching Unreal Fest Online 2020 I will do a pull request, I have to check it because I did also a small change to allow z axis control.

Great, but don't feel obliged. I'll improve these declarations in the next update.

That being said, I'm interested in your modifications about z-axis control, if this is something we can enable / disable with a UPROPERTY boolean or something.

Fixed by your PR for most of them.