//设置一个摄像机或其他对象是否使用绝对旋转 CameraSpring->SetUsingAbsoluteRotation(true); // Don't want arm to rotate when character does CameraSpring->TargetArmLength = 0.f; //设置Springarm的相对旋转 CameraSpring->SetWorldRotation(FRotator(-90.f, 0.f, 0.f)); //设置spring插座偏移 CameraSpring->SocketOffset = FVector(0, 0, 600);
// 增强输入:移动输入 voidAMyCharacter::Move(const FInputActionValue& Value) { // input is a Vector2D FVector2D MovementVector = Value.Get<FVector2D>();
if (Controller != nullptr) { // find out which way is forward const FRotator Rotation = Controller->GetControlRotation(); const FRotator YawRotation(0, Rotation.Yaw, 0);
// get forward vector const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
// get right vector const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
// add movement AddMovementInput(ForwardDirection, MovementVector.Y); AddMovementInput(RightDirection, MovementVector.X); }
// Called to bind functionality to input // 增强输入的绑定 voidAMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent);
// Moving EnhancedInputComponent->BindAction(IA_Move, ETriggerEvent::Triggered, this, &AMyCharacter::Move); //ETriggerEvent::Triggered 持续触发 Started 单次触发
// Looking //EnhancedInputComponent->BindAction(IA_Look, ETriggerEvent::Triggered, this, &ATgameCharacter::Look); } else { //错误日志 //UE_LOG(LogTemplateCharacter, Error, TEXT("'%s' Failed to find an Enhanced Input component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this)); } }
// Called to bind functionality to input // 增强输入的绑定 voidAMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent);
// Moving EnhancedInputComponent->BindAction(IA_Move, ETriggerEvent::Triggered, this, &AMyCharacter::Move); //ETriggerEvent::Triggered 持续触发 Started 单次触发
// Looking EnhancedInputComponent->BindAction(IA_Look, ETriggerEvent::Triggered, this, &AMyCharacter::Look); } else { //错误日志 //UE_LOG(LogTemplateCharacter, Error, TEXT("'%s' Failed to find an Enhanced Input component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this)); } }
// Called to bind functionality to input // 增强输入的绑定 voidAMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent);
// Moving EnhancedInputComponent->BindAction(IA_Move, ETriggerEvent::Triggered, this, &AMyCharacter::Move); //ETriggerEvent::Triggered 持续触发 Started 单次触发
// Looking EnhancedInputComponent->BindAction(IA_Look, ETriggerEvent::Triggered, this, &AMyCharacter::Look); } else { //错误日志 //UE_LOG(LogTemplateCharacter, Error, TEXT("'%s' Failed to find an Enhanced Input component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this)); } }