HI all,
I am reading Leaning c++ by Creating Games with UE4, when i am trying spawn a bullet, it fails.
FVector fwd = GetActorForwardVector();
FVector nozzle = GetMesh()->GetBoneLocation("RightHand");
nozzle += fwd * 155;// move it fwd of the monster so it doesn't
// collide with the monster model
FVector toOpponent = thing->GetActorLocation() - nozzle;
toOpponent.Normalize();
ABullet* bullet = GetWorld()->SpawnActor<ABullet>(
BPBullet, nozzle, RootComponent->GetComponentRotation());
if (bullet)
{
bullet->Firer = this;
bullet->ProxSphere->AddImpulse(
toOpponent * BulletLaunchImpulse);
GEngine->AddOnScreenDebugMessage(0, 5.f,
}
else
{
GEngine->AddOnScreenDebugMessage(0, 5.f,
FColor::Yellow, "monster: no bullet actor could be spawned. is the bullet overlapping something ? ");
}
the spawn return null all the time. then I clear the static mesh on bullet, it can spawn correctly.
Is there something wrong?