It's not supposed to, this is just zooming in and out. If you want to clamp it to a min and max you will need to add a min/max value and then use `FMath::Clamp(NewZoomValue, MinZoomValue, MaxZoomValue);`
ZoomAxisValue will never be greater then 1 or less then -1. You would want something like this. ``` const float Direction = Value.Get(); const NewTargetArmLength = CameraBoom->TargetArmLength + (ZoomAxisValue * ZoomStep); FMath::Clamp(NewTargetArmLength, MinZoom, MaxZoom); ``` `FMath::Clamp()` Is just your `if` statement but less error prone and easier to read because it's more direct.
NewTargetArmLength is just a variable to hold the new value. Your code should look like this. ``` const float Direction = Value.Get(); const NewTargetArmLength = CameraBoom->TargetArmLength + (ZoomAxisValue * ZoomStep); CameraBoom->TargetArmLength = FMath::Clamp(NewTargetArmLength, MinZoom, MaxZoom); ```
Very helpful, thank you very much!
Btw it zooms beyond the Character.
It's not supposed to, this is just zooming in and out. If you want to clamp it to a min and max you will need to add a min/max value and then use `FMath::Clamp(NewZoomValue, MinZoomValue, MaxZoomValue);`
@@sudokid where do i add the Clamp
if i have ?
const float ZoomAxisValue = Value.Get();
if (MinZoom >= ZoomAxisValue || MaxZoom >= ZoomAxisValue)
{
CameraBoom->TargetArmLength += ZoomAxisValue * ZoomStep;
}
ZoomAxisValue will never be greater then 1 or less then -1. You would want something like this.
```
const float Direction = Value.Get();
const NewTargetArmLength = CameraBoom->TargetArmLength + (ZoomAxisValue * ZoomStep);
FMath::Clamp(NewTargetArmLength, MinZoom, MaxZoom);
```
`FMath::Clamp()` Is just your `if` statement but less error prone and easier to read because it's more direct.
@@sudokid What is NewTargetArmLength ??
NewTargetArmLength is just a variable to hold the new value. Your code should look like this.
```
const float Direction = Value.Get();
const NewTargetArmLength = CameraBoom->TargetArmLength + (ZoomAxisValue * ZoomStep);
CameraBoom->TargetArmLength = FMath::Clamp(NewTargetArmLength, MinZoom, MaxZoom);
```
Could I ask how you get CameraBoom->TargetArmLength component in c++?
`CameraBoom->TargetArmLength`
@@sudokid thank you I have figured out