Spawn Actor, but ignore yourself, but how right?

My character spawns a bullet out of a socket.
It looks very fitting.

But only if I set the collision conditions to “IgnoreOnlyPawn”, the bullet flies forward nicely.
At the spawn position I don’t want to change anything, so how I just ignore the own character at spawn?
I see a possibility with ,SetOwner()´´

But how exactly, an example please. I am still a beginner in C++.

Depends what your bullet/projectile is, but I handle this by temporarily ignoring the projectiles’ owner during projectile movement.



FTransform SpawnTM(ShootDir.Rotation(), Origin);
AProjectile* Projectile = Cast<AProjectile>(UGameplayStatics::BeginDeferredActorSpawnFromClass(this, ProjectileClass, SpawnTM));
if (Projectile)
{
Projectile->SetOwner(this);
Projectile->ProjectileCollision->MoveIgnoreActors.Add(GetOwner());
Projectile->ProjectileCollision->MoveIgnoreActors.Add(GetInstigator());
Projectile->InitVelocity(ShootDir);

UGameplayStatics::FinishSpawningActor(Projectile, SpawnTM);
}


Thanks for the tip, but it does not want to compile, it does not know “ProjectileCollision”.
My Bullet is an actor with sphere, and projectilemovement.

Code:
AKugel* TempKugel = GetWorld()->SpawnActor<AKugel>(KugelKlasse, SpawnOrt, SpawnRichtung);
TempKugel->SetOwner(this);
TempKugel->ProjectileCollision->MoveIgnoreActors.Add(GetOwner());

I can’t get any further.

It won’t compile directly, it’s a snippet from my code - ProjectileCollision is the equivalent of whatever your collision sphere is.

Oh wonderful, it really helped me, it works, thank you very much. That was a very specific question, very well answered, thank you.

How do you find some special functions. So far I orientate myself by instructions. I still miss the good workflow.

You should probably study the ShooterGame template project from Epic. It’s a rite-of-passage for any UE4 C++ developer to be honest, and will give you a headstart.

Also most if not all of this is exposed in Blueprint, which you should spend a lot of time in before switching to C++ because it’s a much faster way of learning UE’s API and the way it expects you to build the game.

Thank you very much, I will start right away. I’ve been working with BP for 3 years now, but I had the impression that if you really want to realize a game one day, you should know with C++.