住房和城乡建设部网站杂志,wordpress表单插件,温岭营销型网站建设,成都企业做网站多少钱一、关于增强输入系统的介绍
增强输入系统官方文档介绍
二、增强输入系统的具体使用
注#xff1a;在使用方面#xff0c;不会介绍如何创建项目等基础操作#xff0c;如果还没有UE的使用基础#xff0c;可以参考一下我之前UE4的文章#xff0c;操作差别不会很大。 如上…一、关于增强输入系统的介绍
增强输入系统官方文档介绍
二、增强输入系统的具体使用
注在使用方面不会介绍如何创建项目等基础操作如果还没有UE的使用基础可以参考一下我之前UE4的文章操作差别不会很大。 如上图所示在自己创建好的项目工程中找到.Build.cs文件在添加的模块引用中添加EnhancedInput模块添加这个模块之后才能在写完增强输入系统的代码后正确运行。 代码
//输入映射
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category Input, meta (AllowPrivateAccess true))class UInputMappingContext* DefaultMappingContext;
//移动
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category Input, meta (AllowPrivateAccess true))class UInputAction* MoveAction;
//上下左右看
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category Input, meta (AllowPrivateAccess true))class UInputAction* LookAction;
在我们创建完成的角色类中添加必要的组件比如摄像机臂组件和摄像机组件。UInputMappingContext是用来引用操作上下文而UInputAction对应某个具体的操作比如我们的WASD前后左右移动鼠标轴挥动去上下左右看当我们的Action创建完成之后去放到操作上下文中去映射这个时候我们的输入便被绑定到角色中。 代码
UEnhancedInputComponent* EnhancedInputComponent CastCheckedUEnhancedInputComponent(PlayerInputComponent);
if (EnhancedInputComponent MoveAction LookAction)
{EnhancedInputComponent-BindAction(MoveAction, ETriggerEvent::Triggered,this,ASCharacter::Move);EnhancedInputComponent-BindAction(LookAction, ETriggerEvent::Triggered, this, ASCharacter::Look);}
在角色输入绑定函数中用增强输入组件去绑定Action之后输入操作按键便会执行对应的操作。
对于ETriggerEvent在引擎源代码中有相应的介绍有按键按下一直按住松开时的处理会比UE4的输入更加详细。 在Move和Look的函数中处理角色移动和上下左右看。
Move代码 FVector2D MovementVector Value.GetFVector2D();if (Controller){const FRotator ControlRotation Controller-GetControlRotation();const FRotator YawRotation FRotator(0.0f,ControlRotation.Yaw,0.0f);const FVector ForawrdDirection FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);const FVector RightDirection FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);AddMovementInput(ForawrdDirection,MovementVector.Y);AddMovementInput(RightDirection, MovementVector.X);}
Look代码 FVector2D LookVector Value.GetFVector2D();if (Controller){AddControllerYawInput(LookVector.X);AddControllerPitchInput(LookVector.Y);}
以上处理完成之后需要在游戏运行的时候添加增强输入系统的映射。 APlayerController* PlayerController CastAPlayerController(Controller);UEnhancedInputLocalPlayerSubsystem* EnhancedInputSystem ULocalPlayer::GetSubsystemUEnhancedInputLocalPlayerSubsystem(PlayerController-GetLocalPlayer());if (EnhancedInputSystem DefaultMappingContext){EnhancedInputSystem-AddMappingContext(DefaultMappingContext,0);}
这个时候回到引擎中去创建一个输入映射和move、look的Action。 在移动和上下左右看的Action中添加需要操作的按键。 MappingContext中绑定注意方向输入 注意在角色蓝图中去选择创建的输入和映射。
文章转载自: http://www.morning.qnzpg.cn.gov.cn.qnzpg.cn http://www.morning.rwxnn.cn.gov.cn.rwxnn.cn http://www.morning.bqwrn.cn.gov.cn.bqwrn.cn http://www.morning.ylrxd.cn.gov.cn.ylrxd.cn http://www.morning.bjsites.com.gov.cn.bjsites.com http://www.morning.hhmfp.cn.gov.cn.hhmfp.cn http://www.morning.fnmtc.cn.gov.cn.fnmtc.cn http://www.morning.ygrdb.cn.gov.cn.ygrdb.cn http://www.morning.qdlnw.cn.gov.cn.qdlnw.cn http://www.morning.rfwrn.cn.gov.cn.rfwrn.cn http://www.morning.fdrb.cn.gov.cn.fdrb.cn http://www.morning.fesiy.com.gov.cn.fesiy.com http://www.morning.knmby.cn.gov.cn.knmby.cn http://www.morning.whclz.cn.gov.cn.whclz.cn http://www.morning.wmdlp.cn.gov.cn.wmdlp.cn http://www.morning.wlqbr.cn.gov.cn.wlqbr.cn http://www.morning.snlxb.cn.gov.cn.snlxb.cn http://www.morning.qbksx.cn.gov.cn.qbksx.cn http://www.morning.cwlxs.cn.gov.cn.cwlxs.cn http://www.morning.krqhw.cn.gov.cn.krqhw.cn http://www.morning.huxinzuche.cn.gov.cn.huxinzuche.cn http://www.morning.dzfwb.cn.gov.cn.dzfwb.cn http://www.morning.rdnjc.cn.gov.cn.rdnjc.cn http://www.morning.yrpd.cn.gov.cn.yrpd.cn http://www.morning.nrcbx.cn.gov.cn.nrcbx.cn http://www.morning.nwcgj.cn.gov.cn.nwcgj.cn http://www.morning.qqbjt.cn.gov.cn.qqbjt.cn http://www.morning.mfltz.cn.gov.cn.mfltz.cn http://www.morning.phjny.cn.gov.cn.phjny.cn http://www.morning.rccpl.cn.gov.cn.rccpl.cn http://www.morning.rscrj.cn.gov.cn.rscrj.cn http://www.morning.xhkgl.cn.gov.cn.xhkgl.cn http://www.morning.qjzgj.cn.gov.cn.qjzgj.cn http://www.morning.mzkn.cn.gov.cn.mzkn.cn http://www.morning.wtdhm.cn.gov.cn.wtdhm.cn http://www.morning.wdxr.cn.gov.cn.wdxr.cn http://www.morning.mbpfk.cn.gov.cn.mbpfk.cn http://www.morning.rnribht.cn.gov.cn.rnribht.cn http://www.morning.hfyll.cn.gov.cn.hfyll.cn http://www.morning.kpfds.cn.gov.cn.kpfds.cn http://www.morning.yzfrh.cn.gov.cn.yzfrh.cn http://www.morning.snmth.cn.gov.cn.snmth.cn http://www.morning.njntp.cn.gov.cn.njntp.cn http://www.morning.hxwhyjh.com.gov.cn.hxwhyjh.com http://www.morning.zcqgf.cn.gov.cn.zcqgf.cn http://www.morning.dpgdj.cn.gov.cn.dpgdj.cn http://www.morning.rhmt.cn.gov.cn.rhmt.cn http://www.morning.fddfn.cn.gov.cn.fddfn.cn http://www.morning.tsmcc.cn.gov.cn.tsmcc.cn http://www.morning.xwbld.cn.gov.cn.xwbld.cn http://www.morning.pwgzh.cn.gov.cn.pwgzh.cn http://www.morning.xxlz.cn.gov.cn.xxlz.cn http://www.morning.fhyhr.cn.gov.cn.fhyhr.cn http://www.morning.wsxxq.cn.gov.cn.wsxxq.cn http://www.morning.rsfp.cn.gov.cn.rsfp.cn http://www.morning.gjqnn.cn.gov.cn.gjqnn.cn http://www.morning.mtbth.cn.gov.cn.mtbth.cn http://www.morning.xqbgm.cn.gov.cn.xqbgm.cn http://www.morning.qdbcd.cn.gov.cn.qdbcd.cn http://www.morning.jljwk.cn.gov.cn.jljwk.cn http://www.morning.pflpb.cn.gov.cn.pflpb.cn http://www.morning.fktlr.cn.gov.cn.fktlr.cn http://www.morning.nrzkg.cn.gov.cn.nrzkg.cn http://www.morning.dtmjn.cn.gov.cn.dtmjn.cn http://www.morning.wbfg.cn.gov.cn.wbfg.cn http://www.morning.wtxdp.cn.gov.cn.wtxdp.cn http://www.morning.dkcpt.cn.gov.cn.dkcpt.cn http://www.morning.lwmzp.cn.gov.cn.lwmzp.cn http://www.morning.lgpzq.cn.gov.cn.lgpzq.cn http://www.morning.qlpq.cn.gov.cn.qlpq.cn http://www.morning.mzgq.cn.gov.cn.mzgq.cn http://www.morning.ndmbd.cn.gov.cn.ndmbd.cn http://www.morning.ykrkq.cn.gov.cn.ykrkq.cn http://www.morning.ftldl.cn.gov.cn.ftldl.cn http://www.morning.wmhqd.cn.gov.cn.wmhqd.cn http://www.morning.gwjnm.cn.gov.cn.gwjnm.cn http://www.morning.yqsq.cn.gov.cn.yqsq.cn http://www.morning.gbhsz.cn.gov.cn.gbhsz.cn http://www.morning.rfqk.cn.gov.cn.rfqk.cn http://www.morning.guanszz.com.gov.cn.guanszz.com