TakeDamage EvetInstigator could be null

I noticed in the refactored PullTrigger() the AController* OwnerController is set with a call to the function GetOwnerController() and then used in TakeDamage().

The new function GetOwnerController() can return nullptr but this is not checked and could be passed into TakeDamage().

Question: Does this matter and how does TakeDamage() behave when the EventInstigator could be null. I looked at the online docs but couldn’t find any information.

I assume that damage can be done to a Pawn by an Actor that doesn’t have a Controller e.g. a trap, or falling rocks, etc.

  1. It doesn’t matter if nullptr is passed in. The TakeDamage function should check that (Super::TakeDamage that is called checks if it’s nullptr and does some extra stuff if it’s not)
  2. Your assumption is correct.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms