How to make an attached camera fixed on distance from a pawn?

If you are using a spring arm uncheck “do collision test”

I attached a camera to a pawn with a specified distance, but there is a problem when moving the pawn, the camera goes away on its own when the pawn is trapped behind a static mesh. How can I fix it?

I am not using spring arm. using Camera->SetRelativeLocation

I am not using spring arm. using Camera->SetRelativeLocation

can give more details to have a clear undrstanding of the situation

Yes. I have attached a camera to a pawn and I also use some inputs to move the pawn around the level and it moves pretty good and the camera follows it. but when the pawn hits something and stops and I am still holding input keys to move, the pawn stays in its current location and only camera moves then I cannot see the pawn anymore. I want camera not to move if the pawn is caught . see. although I have attached the camera and specified a distance from the pawn using these codes:
Camera->AttachTo(RootComponent);
Camera->SetRelativeLocation(FVector(-250.0f, 0.0f, 250.0f));
Camera->SetRelativeRotation(FRotator(-45.0f, 0.0f, 0.0f));
MySphereComponent->AttachTo(RootComponent);
but it looks like that distance increases when pawn is caught.
my code is something like this

if you write and play it and move backward till you get that table then continue moving, the pawn will be caught behind the table and only camera moves
and also if you fall off the level, camera wont follow you. i want camera be always following.

I also used spring arm but the result was the same

Ah I see now , I Think this will solve your problem

Don’t attach “YouCollisionComponent” to your pawn RootComponent and make sure :

RootComponent = YouCollisionComponent;

yes… Thank you :)))