본문 바로가기

언리얼엔진/FirstProject

마우스휠로 줌하기

인풋액션 IA_Zoom을만든다 Axis1D로 한다.

IMC_Main을 열어 추가하고 Mouse Wheel Axis를 추가해준다.

TPSPlayer.h에 변수를 추가해주고

	UPROPERTY(EditAnywhere, Category = "Input")
	UInputAction* WheelIA;

TPSPlayer.cpp에 바인딩해주고 정의해준다.

void ATPSPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);
	//입력 바인딩
	if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))
	{
		.........
		EnhancedInputComponent->BindAction(WheelIA, ETriggerEvent::Triggered, this, 
            &ATPSPlayer::InputWheel);
	}
}

void ATPSPlayer::InputWheel(const FInputActionValue& Value)
{
	const float _currentValue = Value.Get<float>();
	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Magenta, TEXT("Wheel" ));
	springArmComp->TargetArmLength = FMath::Clamp<float>(springArmComp->TargetArmLength 
               - _currentValue*100, 150.f,800.f);
}

'언리얼엔진 > FirstProject' 카테고리의 다른 글

인공지능 적 만들기  (0) 2023.11.15
무기 장착하기  (1) 2023.11.14
Player Attack - Animation Montage만들기  (0) 2023.11.02
적에너미 만들기  (0) 2023.11.02
ThirdPerson Blueprint Child만들기  (1) 2023.11.02