小编Kam*_*len的帖子

使用 OnComponentHit UE4 C++ 进行碰撞检测

我遇到碰撞问题。我想做简单的射弹。我制作了一个具有根、球体和网格组件的 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)

c++ unreal-engine4

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

unreal-engine4 ×1