我遇到碰撞问题。我想做简单的射弹。我制作了一个具有根、球体和网格组件的 Actor。当这个演员击中目标物体时,什么也没有发生。我已经尝试了很多方法,也与
void OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
void OnOverlapEnd(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
Run Code Online (Sandbox Code Playgroud)
功能,但没有任何结果..
这是我的自定义射弹的构造函数:
AProjectile_2::AProjectile_2()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
RootComponent = Root;
mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("staticMesh"));
static ConstructorHelpers::FObjectFinder<UStaticMesh>SphereMeshAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
if (SphereMeshAsset.Succeeded())
{
mesh->SetStaticMesh(SphereMeshAsset.Object);
mesh->SetWorldScale3D(FVector(0.2f));
}
mesh->SetEnableGravity(true);
mesh->SetSimulatePhysics(true);
mesh->SetupAttachment(Root); …Run Code Online (Sandbox Code Playgroud)