查看“U++ 增强输入”的源代码
←
U++ 增强输入
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
<syntaxhighlight lang="cpp"> // Fill out your copyright notice in the Description page of Project Settings. #include "IAPawnTest.h" // Sets default values AIAPawnTest::AIAPawnTest() { // Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; } // Called when the game starts or when spawned void AIAPawnTest::BeginPlay() { Super::BeginPlay(); // 在你的cpp中... if (APlayerController* PC = Cast<APlayerController>(GetController())) { if (UEnhancedInputLocalPlayerSubsystem* InputSystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer())) { InputSystem->AddMappingContext(InputMapping, 0); } } } // Called every frame void AIAPawnTest::Tick(float DeltaTime) { Super::Tick(DeltaTime); } // Called to bind functionality to input void AIAPawnTest::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); UEnhancedInputComponent* Input = Cast<UEnhancedInputComponent>(PlayerInputComponent); // 你可以通过更改"ETriggerEvent"枚举值,绑定到此处的任意触发器事件 Input->BindAction(IA_ATTACK, ETriggerEvent::Triggered, this, &AIAPawnTest::FUNC_ATTACK); } void AIAPawnTest::FUNC_ATTACK(const FInputActionValue& Value) { // 获取此处所需任意类型的输入动作的值... FVector VectorValue = Value.Get<FVector>(); FVector2D AxisValue2D = Value.Get<FVector2D>(); float FloatValue = Value.Get<float>(); bool BoolValue = Value.Get<bool>(); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, BoolValue ? TEXT("true") : TEXT("false")); // 在此处实现你的精彩功能! } </syntaxhighlight> <syntaxhighlight lang="cpp"> // Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/Pawn.h" #include "InputActionValue.h" #include "EnhancedInputSubsystems.h" #include "GameFramework/PlayerController.h" #include "EnhancedInputComponent.h" #include "IAPawnTest.generated.h" UCLASS() class PRACTICE_API AIAPawnTest : public APawn { GENERATED_BODY() public: // Sets default values for this pawn's properties AIAPawnTest(); protected: // Called when the game starts or when spawned virtual void BeginPlay() override; public: // Called every frame virtual void Tick(float DeltaTime) override; // Called to bind functionality to input virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; void FUNC_ATTACK(const FInputActionValue& Value); // 将映射上下文公开为头文件中的属性... UPROPERTY(EditAnywhere, Category = "Input") class UInputMappingContext* InputMapping; UPROPERTY(EditAnywhere, Category = "Input") class UInputAction* IA_ATTACK; }; </syntaxhighlight>
返回至“
U++ 增强输入
”。
导航菜单
个人工具
登录
命名空间
页面
讨论
大陆简体
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
基础知识
正则表达式
Markdown
分布式
项目管理
系统集成项目管理基础知识
云原生
Docker
云原生安全
云原生词汇表
十二因素应用
Kubernetes
音频处理
音频合成
Edge-tts
CMS系统
Docsify
VuePress
Mediawiki
自动生成
Marp
CI/CD
GitLab
设计
颜色
平面设计
AI
数字人
操作系统
GNU/Linux
数据库
Mysql
工具
链入页面
相关更改
特殊页面
页面信息