Hi Guys, I asked this yesterday but I haven’t been able to solve it yet, so any help would be appreciated,
So I have the Static Mesh and a Capsule Collision Component set up has:
StaticMeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("One Handed Mesh"));
RootComponent = StaticMeshComp;
OneHandedCollision = CreateDefaultSubobject<UCapsuleComponent>(TEXT("One Handed Collision"));
OneHandedCollision->SetCapsuleRadius(10.0f);
OneHandedCollision->SetSimulatePhysics(false);
OneHandedCollision->SetCapsuleHalfHeight(48.0f);
OneHandedCollision->SetGenerateOverlapEvents(true);
OneHandedCollision->SetNotifyRigidBodyCollision(true);
OneHandedCollision->SetCollisionProfileName("OnHandWeapon");
OneHandedCollision->SetRelativeLocation(FVector(0.0f, 0.0f, 65.0f));
OneHandedCollision->OnComponentHit.AddDynamic(this, &AOneHandedWeapon::OnHit);
OneHandedCollision->OnComponentBeginOverlap.AddDynamic(this, &AOneHandedWeapon::BeginOverlap);
OneHandedCollision->SetupAttachment(RootComponent);
in my Class constructor
and the .h file has the function set has:
UFUNCTION()
void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
UFUNCTION()
void BeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
I Have been able to get into the Hit function when I enable the simulate physics on the capsule component, but it only hits the block out of the level and not the characters that I have set up for testing, so I’m not 100% sure of what is happening.
This is the Capsule components and it’s attached events:
and the collision profile that the weapon and collider use:
I was able to test it a little bit by creating a giant sword blueprint weapon from the same C++ code Has seen in the image
but the overlap result is confusing, since it basically overlapped itself, instead of overlapping the player: