我已经尝试添加这个功能很长一段时间了。然而,我似乎忽略了一些东西。
所以我想增加一个弹药数,一个类似于地震或毁灭的弹药数。在地图上分发弹药。枪可以发射多达10次,然后停止,但当我试图重新加载与弹药拾音器重叠,静态网格没有反应。静态mash父类是一个蓝图(参与者),它的父类是ammocrate.cpp (下面),它也是一个参与者。这就是我到目前为止所做的。
AmmoCrate.cpp
AAmmoCrate::AAmmoCrate()
{
PrimaryActorTick.bCanEverTick = true;
Count = 10;
SphereRadius = 100.0f;
TouchSphere = CreateDefaultSubobject<USphereComponent>(TEXT("TouchSphereComponent"));
TouchSphere->InitSphereRadius(SphereRadius);
TouchSphere->SetCollisionProfileName("Trigger");
RootComponent = TouchSphere;
StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMeshComponent"));
StaticMesh->SetupAttachment(RootComponent);
TouchSphere->OnComponentBeginOverlap.AddDynamic(this, &AAmmoCrate::OnOverlapBegin);
}
void AAmmoCrate::OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
AFirstPersonCharacter *FPCharacter = Cast<AFirstPersonCharacter>(OtherActor);
AMannequin* TPCharacter = Cast<AMannequin>(OtherActor);
AGun *Gun = Cast<AGun>(OtherActor);
if (TPCharacter)
{
Gun->AmmoPool = Gun->AmmoPool + Count;
this->Destroy();
}之后,我创建了一个类似于OnReload()函数的OnFire()函数,在该函数中,我从第一个Person字符调用它。
FirstPersonCharacter.cpp
void AFirstPersonCharacter::OnReload()
{
Gun->OnReload();
}我在UE_LOG函数上设置了一个OnReload调用--它甚至没有注销弹药箱与之重叠的情况,我在这里遗漏了什么?
发布于 2018-08-22 11:51:29
在FPS字符胶囊和弹药箱对撞机的碰撞设置中,是否检查了GenerateOverlapEvents?两个对撞机是否都在适当的通道上,可以产生重叠事件?
https://stackoverflow.com/questions/51702467
复制相似问题