I have this third person character blueprint in which I'm trying to hide the character mesh if the CameraVisibilitySphere component overlaps the character. It actually works, but only if the character moves.
If simply I move the character close to an object, rotate the camera so that it collides with the object and gets closer to the character, the mesh won't disappear. But if I just move the character a bit, no matter in what direction and so that the sphere still overlaps with the character, Is Overlapping Component returns true as it should and the mesh is gone.
When the mesh is not visible, without moving the character, and I rotate the camera so that the visibility sphere doesn't overlap anymore, nothing happens. If then I move the character, the mesh reappears.
I tried using OnComponentBegin/EndOverlap and I've also coded it, but nothing changes, it shows the same behaviour. The code I set the sphere with is this:
CameraVisibilitySphere = CreateDefaultSubobject<USphereComponent>(TEXT("CameraVisibilitySphere"));
CameraVisibilitySphere->SetupAttachment(FollowCamera);
CameraVisibilitySphere->SetSphereRadius(12.0f);
CameraVisibilitySphere->SetCollisionProfileName(TEXT("Actor"));
CameraVisibilitySphere->bGenerateOverlapEvents = true;
CameraVisibilitySphere->OnComponentBeginOverlap.AddDynamic(this, &ABatteryCollectorCharacter::OnCharacterBeginOverlap);
CameraVisibilitySphere->OnComponentEndOverlap.AddDynamic(this, &ABatteryCollectorCharacter::OnCharacterEndOverlap);
BTW the character's capsule is set to generate overlap events and to overlap with the camera.
What should I do to make this work? And, most importantly, do overlap events get called on child components of the same actor?
I'm new to Unreal, so I still don't know the environment very well.