Camera zoom not working

I wanted to create an orbit cam and shoulder cam. Here is the code

FVector Loc, Pos, HitLocation, HitNormal, EyeLoc, FinalPos;
	FRotator Rot, EyeRot;
	FPOV OrigPOV;
	FMath math = FMath();
	AShooterCharacter* TypedTarget = Cast(OutVT.Target);
//It should be header file, but for now it will work.
	FVector LowOffset = FVector(-100.0f,0,20.0f);
	FVector MidOffset = FVector(-200.0f,0.0f,20.0f);
	FVector HighOffset = FVector(-100.0f,20.0f,20.0f);
 
	FVector FinalOffset = MidOffset;
 
	OrigPOV = OutVT.POV;
	OutVT.Target->GetActorEyesViewPoint(EyeLoc, EyeRot);
	Loc = OutVT.Target->GetActorLocation();
 

	FVector const Offset = FVector(-150.0f, 0.0f, 0.0f);
	FinalPos = EyeLoc;
	FinalPos += FRotationMatrix(EyeRot).TransformVector(FinalOffset);
 
	OutVT.POV.Location = FinalPos;
	OutVT.POV.Rotation = EyeRot;
	
	const bool TargetingView = TypedTarget->IsTargeting();

	if (TargetingView)
	{
		MidOffset = FVector(-100.0f,20.0f,20.0f);
	}

basically right click causes targetingview to go true which is working but what i did is that it will go to a shouldercam offset which is not happening, it stays orbit if when targeting. Any help please.

i changed const bool bBlocked to just bool but still not working

Hi Eshwar,

MidOffset is a local variable, and you are adjusting it after you have used it, so it will have no effect.

Cheers,
Michael Noland

ok i did that but now it crashes when i die

You didn’t specify where it is crashing but probably OutVT.Target is no longer an AShooterPawn, so TypedTarget is NULL.

Cheers,
Michael Noland

Ah thanks now i know what to do!