Camera/Spring Arm not working correctly

As near as I can tell I’ve set this up correctly but the spring arm/camera does not seem to be position correctly relative to the tank.
Using the exact same settings as I saw in the video my camera view seems to be below the floor and does not follow the tank when moving.

#include "Tank.h"

#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"

	SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
	Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
void ATank::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
	PlayerInputComponent->BindAxis(TEXT("MoveForward"), this, &ATank::Move);

void ATank::Move(float Value)
	FVector DeltaLocation = FVector::ZeroVector;
	// X = Value * DeltaTime * Speed
	DeltaLocation.X = Value * GetWorld()->DeltaTimeSeconds * Speed;
	AddActorLocalOffset(DeltaLocation, true);

Also, why is rotation and scale missing from the SpringArmComponent transform?

Now it keeps crashing. I can’t even open the project because it immediately crashes

Okay, the crash was my fault. I added a UE_LOG to display the name of the RootComponent which caused an access violation because it was null.
Turns out my SpringArmComponent was on the BP_Tank itself and not the CapsuleCollider.

The only way I could fix this was to delete BP_Tank and recreate it from the C++ class and add the components back “the right way” because it wouldn’t let me reorder them in the blueprint editor.

I don’t recall anything being this obtuse in Unity.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms