This has happened to me with a few different projects.
In all of them, I started with a first person C++ template, and added a zoom function for my character, which just modifies the spring arm length and FOV, removed gun mesh and related functions, and created a landscape. I’ll include the zoom code, since it’s pretty much the only thing I modified from the template.
I’m having two issues. First, the character starts spawning at the origin rather than network player start for every level in my project. And even if I modify my level so that nothing will collide with the origin, the character can’t move or jump. My zoom function still works though.
The odd thing is I don’t know exactly when this starts happening. I’ve had my project working fine for a bit (movement and spawn location are correct) and then at some point this happens, but as far as I can tell, it’s not after any significant changes.
Additionally, I have copied the character and migrated the landscape to another project, and for now this one works fine.
So far, what I’ve seen recommended on the forum doesn’t fix my issue, as I’ve already checked the following:
- Player start is not overlapping any objects, and does not have a bad size tag
- Correct game mode is set in Maps and Modes and World settings
- Correct pawn is set in my game mode
- I added a print function to my movement functions, so I know that they are firing
- Character is set to spawn at default player start (from the Play button)
- Player inputs are configured
Modified camera in my character’s constructor:
FirstPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera"));
FirstPersonCameraComponent->bUsePawnControlRotation = true;
FirstPersonCameraComponent->FieldOfView = 90.0f;
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
OurCameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArm"));
OurCameraSpringArm->SetupAttachment(RootComponent);
OurCameraSpringArm->TargetArmLength = 100.f;
OurCameraSpringArm->bEnableCameraLag = true;
OurCameraSpringArm->CameraLagSpeed = 3.0f;
FirstPersonCameraComponent->SetupAttachment(OurCameraSpringArm, USpringArmComponent::SocketName);
Zoom functions:
void ABlueTilesCharacter::CameraZoomIn()
{
if ((Controller != NULL))
{
ZoomControl = true;
}
}
void ABlueTilesCharacter::CameraZoomOut()
{
if ((Controller != NULL))
{
ZoomControl = false;
}
}
and in my character’s Tick I have:
float ArmLength = OurCameraSpringArm->TargetArmLength;
if (ZoomControl == true)
{
ZoomFactor += DeltaTime / 0.5f; //Zoom in over half a second
}
else
{
ZoomFactor -= DeltaTime / 0.5f; //Zoom out over a quarter of a second
}
ZoomFactor = FMath::Clamp<float>(ZoomFactor, 0.0f, 1.0f);
//Blend our camera's FOV and our SpringArm's length based on ZoomFactor
FirstPersonCameraComponent->FieldOfView = FMath::Lerp<float>(100.0f, 70.0f, ZoomFactor);
OurCameraSpringArm->TargetArmLength = FMath::Lerp<float>(100.0f, 50.0f, ZoomFactor);