Hi, I have an four-legged animal character blueprint (having a C++ base class) for which the default vertical shape of the capsule doesn’t fit (and the shape of the capsule cannot be made horizontal, UE 4.16.2). I searched for posts about how to workaround the problem, but I only found partial information and this is still not working for me. So first thing seems to be using a box collision component to define the collision instead of the capsule. This is what I did, I scaled the capsule down, removed its collision settings, added a box collision to the blueprint hierarchy (under Capsule since this is the root component…) and set it up for collision. Result: collision not working, character falls through the floor. Second attempt, I read that it may help to make the box collision the root component (i.e. as replacement of the capsule). So I did this in the C++ base class of my character blueprint:
.h file:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Setup, meta = (AllowPrivateAccess = "true"))
class UBoxComponent* BoxCollisionComponent;
.cpp file:
MyCharacter::MyCharacter()
{
PrimaryActorTick.bCanEverTick = true;
BoxCollisionComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxCollision"));
BoxCollisionComponent->InitBoxExtent(FVector(5.1875f, 0.875f, 2.1875f));
BoxCollisionComponent->SetCollisionProfileName(UCollisionProfile::Pawn_ProfileName);
BoxCollisionComponent->CanCharacterStepUpOn = ECB_No;
BoxCollisionComponent->bShouldUpdatePhysicsVolume = true;
BoxCollisionComponent->bCheckAsyncSceneOnMove = false;
BoxCollisionComponent->SetCanEverAffectNavigation(false);
BoxCollisionComponent->bDynamicObstacle = true;
RootComponent = BoxCollisionComponent;
// reparent the capsule
GetCapsuleComponent()->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepWorldTransform);
}
Using this, the root is properly replaced by the box collision comp. But my character is still falling through the floor… Also, i cannot see the box collision in the Blueprint editor, so it is difficult to size it. For this I had to create a temp. collision box component under the root, scale it then I copied size values into the C++ constructor (InitBoxExtent) and removed it.
So my questions:
- am I on the right track? Do I really need to make the box collision comp. as root?
- what I am missing since I still have my character falling through the floor after adding the box collision component as root?
- how can I see my box boundaries/position into the Blueprint editor once I have it set as root comp?
Thanks!