Download

Character falling through the ground

I want the Pawn possessed by PlayerController to fall down and stop on the ground like a tetris game, this is the function in the PlayerController:


   

FVector PieceLocation = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorLocation();
FRotator PieceRotation = GetWorld()->GetFirstPlayerController()->GetPawn()->GetActorRotation();
FHitResult HitResult;

PieceLocation.Z += Speed * GetWorld()->GetDeltaSeconds();
GetWorld()->GetFirstPlayerController()->GetPawn()->SetActorLocation(PieceLocation, false);



The piece falls down but it keeps falling even when it reaches the ground. I tried enabling bSweep and I also tried TeleportTo instead of SetActorLocation but nothing changes. I enabled collisions in the blueprint editor and I’m not using physics.
How can I solve that?

It seems to me, that you continously add a movement direction (in your case: down) to your Piece. I think if it should collide with the Floor, then you have to stop the movement. I would do a triggerbox on the ground and then, if you hit it, stop the movement.

Does the floor and your possesed pawn also have some collision on them? I’m not entirely sure, but a Pawn may need a collision as it’s root to allow simulation of physics. They both need to be setup to block whatever the other type is.