AimAt Function

Hi i found that:

GetControlledTank()->FindComponentByClass<<>UTankAimingComponent>()->AimAt(HitLocation);

worked too, calling the TankAimingComponent.cpp member function directly
instead of first calling Tank.cpp’s member function

GetControlledTank()->AimAt(HitLocation);

is there any reason why not to do this?

Personally I’d actually prefer the second one in most situations, since you don’t have to worry about finding the component and can just call the function and let the function do the work. In this situation though, where you’ll most likely only be calling the function from one place, your way is fine too.

Oki
I thought too that there might be some overhead in first finding the component, but i was not sure.

Thanks :slight_smile:

Privacy & Terms