When spawning a c++ Actor from blueprint, why is the GetOwner and GetInstigator null?

anonymous_user_84e00996
Sun, 26 Jun 2016 06:09:55 +0000
Blueprint

I have recently began the journey of learning the c++ ways, and am converting my various knowledge of blueprints into c++.

My current ‘Non Homing Projectile’ is simple. It is meant to be a spawn and travel in the direction that the controller is facing in. Currently in Blueprint, I can simply grab the owner, cast to pawn, and then set the current actor rotation based on getting the controller of the owner: http://puu.sh/pGkrD/079d5b6257.png

I attempted to add the code in c++ to replace the current Blueprint version of this functionality, but the GetOwner and GetInstigator functions both return null as far as I can tell as the only message that prints off is 'My Rotation is Null =(": http://puu.sh/pGkAB/771e01f07b.png

How I am spawning the projectile: http://puu.sh/pGkCF/efb857b1c5.png

Summary: My Blueprint variation of setting the ActorRotation based on the Owner works, but the c++ version does not know of an owner. So is this a product of spawning an actor in blueprints? Or is this a case of c++ constructors firing earlier than I am expecting (this works when I move the code to BeginPlay in c++ of course, but projectile movement being set on construction is what I want). Any help or tips would be appreciated!

2 posts - 1 participant