Find floor not finding my actor

Hey there!

I am in the veeeery early stages of making a 2D game, I have made a class that inherits from APaperCharacter for my main character, and I have made a class called AOceanFloor inheriting from AActor.

The ocean floor has a box component and I run the following code in its constructor to setup some properties and make the box the root component:

MyBox = CreateDefaultSubobject(TEXT(“Box”));
RootComponent = MyBox;

MyBox->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Block);

The character starts in the air atm and falls down and collides with the volume as expected.
However I noticed when trying to move my character that the code considers it to be falling even after it hits the box. I did some digging and found that this is because when the characterMovementComponent is trying to find the floor by calling FindFloor() it does not find my box volume.

I am pretty confused as to why this is since the character is colliding with the floor already. Why could this be happening?

Any help appreciated :slight_smile: Thanks!

You’ll want to make sure the channel you’re tracing on is also blocked.
If you’re tracing on visibility, make sure the visibility channel is blocked by the mesh.

Mesh->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);


In UCharacterMovementComponent::FloorSweepTest TraceChannel is ECC_Pawn as I would expect. I am sort of assuming that channel is the type for the thing that is tracing, rather than what we want to find. And that type is already blocked by the Ocean floor box, unless I misunderstand something here(also demonstrated by the Character being stopped by the volume)

To add more context, this is how i set up collision for the character.

UCapsuleComponent* capsuleComponent = GetCapsuleComponent();
capsuleComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldDynamic, ECollisionResponse::ECR_Block);
capsuleComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block);

The character also collided with a floor I pulled in from the starter content, but still runs into the same issue of not finding the volume during the sweep test.

The issue was that I was setting up these settings in the constructor. Moving the code to begin play for both classes solved this issue at least :smiley:

Now I have a problem that AddMovement Input doesnt cause my character to move, but Jumping via Jump() works at least :smiley:

1 Like