I use a USphereComponent to detect when enemies or other objects approach the player. It worked perfectly in 4.8, but when I updated to 4.9 it started spawning at an offset from the player. I added a line to the constructor to set its location relative to its component to origin:
When creating the sphere component you want to attach it to whatever component you want it to follow (usually the root component). Setting sensoryRadius->AttachTo(RootComponent); should center the sphere component to your capsule component.
Thank you! As a quick follow-up, this code isn’t actually on an AActor, it’s on an actor component childed to the ACharacter who has the capsule collider. What is the correct syntax to find RootComponent in that case? I tried this, but it actually crashed UE and wouldn’t let it start again until I commented it out and deleted the binaries:
Weirdly enough, adding a pointer safety check solved it, even though there isn’t a context I’m aware of in which GetOwner() can return null… either way it works now, thank you again!