AttachTo() disables movement of the car

Hi everybody, I hope you could help me out with this, I’m new to the Unreal Engine.

I’m working with the Vehicle template project that comes UE 4 (not the advanced one, and using C++ not Blueprint). I have to work in code only, due to what my supervisor tells me, so no BP. I want to add a collision box to the front of the car that extends 1000 units forward in order to “scan” the area in front of the car for objects it can collide with. Later I intend to measure the distance between the car and the different objects infront of it.
I have added the following code att the end of the constructor ASimpleCarPawn::ASimpleCarPawn()

CollisionScan = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionScan"));
CollisionScan->SetBoxExtent(FVector(1000.f, 90.f, 70.f));
CollisionScan->SetRelativeLocation(FVector(1200.f, 0.f, 100.f));
CollisionScan->AttachTo(GetMesh());

The problem is that now the car doesn’t move any more, the gear is shifting though, so the code seems to be working, except that the car is not moving. If I however remove the last line CollisionScan->AttachTo(GetMesh()); the car can run as it should, however now the collision box i fixed in the world and does not follow the car around and also its position is not correct in relation to the car, as if the SetRelativeLocation is now using the world as a base point rather then the car itself. To clearify, when i do have the CollisionScan->AttachTo(GetMesh()); code in there, the position of the collision box in relation to the car is correct, but as I said, now the car does not move.

What am I doing wrong? How can I fix this?
Thanks for your time!
/Kristoffer

I looked at the C++ video tutorials and in that a collision sphere is added to the 3rd person character in a similar way, but with CollisionScan->AttachTo(RootComponent); instead. However that doesn’t work for me, the car still can’t move forward.

Try to get a look at the CollisionScan’s mesh properties: maybe it’s set to blockAll, thus blocking the movements and/or keeping the car slightly up in the air.

Yes, thank you! That was the thing. Funny, though, since when I did the same thing in the Code Tutorial from Epic, it worked straight up, without any changes needed. But anyway, it works now. Thank you!