问题描述
我的弹丸类有这个问题。
即使将静态网格物体设置为BlockAllDynamic,它也不会与环境碰撞。生成怪异时,它确实设法移动了我的某些角色。
另一个问题是OnComponentHit不适用于我为角色设置的“胶囊碰撞”(“碰撞”设置为Pawn)。我从OnComponentHit得到响应的唯一时刻是它碰到了我从未创建的“ CollisionCylinder”。它比角色的所有组件都要小。我也在角色和射弹上启用了“模拟命中生成事件”。
#include "KnifeProjectile.h"
#include "Components/StaticmeshComponent.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "Kismet/GameplayStatics.h"
// Sets default values
AKnifeProjectile::AKnifeProjectile()
{
// 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;
ProjectileMesh = CreateDefaultSubobject<UStaticmeshComponent>(TEXT("Projectile Mesh"));
ProjectileMesh->SetupAttachment(Root);
ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("Projectile Movement"));
ProjectileMovement->InitialSpeed = MovementSpeed;
ProjectileMovement->MaxSpeed = MovementSpeed;
}
// Called when the game starts or when spawned
void AKnifeProjectile::BeginPlay()
{
Super::BeginPlay();
ProjectileMesh->OnComponentHit.AddDynamic(this,&AKnifeProjectile::OnHit);
}
void AKnifeProjectile::OnHit(UPrimitiveComponent* HitComp,AActor* OtherActor,UPrimitiveComponent* OtherComp,FVector normalImpulse,const FHitResult& Hit)
{
UE_LOG(LogTemp,Warning,TEXT("%s hit me"),*OtherComp->GetName());
}
// Called every frame
void AKnifeProjectile::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)