//使角色能够左右移动void MoveLeftOrRight (){if (Input.GetKey (KeyCode.A)) {if (currentHorizontalDistance <= -maxHorizontalDistance){return;}transform.Translate (Vector3.left * Time.deltaTime * horizontalMoveSpeed);currentHorizontalDistance -= Time.deltaTime * horizontalMoveSpeed;} else if (Input.GetKey (KeyCode.D)) {if (currentHorizontalDistance >= maxHorizontalDistance){return;}transform.Translate (Vector3.right * Time.deltaTime * horizontalMoveSpeed);currentHorizontalDistance = Time.deltaTime * horizontalMoveSpeed;}else{if (currentHorizontalDistance > 0){transform.Translate (Vector3.left * Time.deltaTime * horizontalMoveSpeed);currentHorizontalDistance -= Time.deltaTime * horizontalMoveSpeed;if (currentHorizontalDistance < 0.f){transform.Translate (Vector3.left * currentHorizontalDistance);currentHorizontalDistance = 0;}}else if (currentHorizontalDistance < 0){transform.Translate (Vector3.right * Time.deltaTime * horizontalMoveSpeed);currentHorizontalDistance = Time.deltaTime * horizontalMoveSpeed;if (currentHorizontalDistance > -0.f){transform.Translate (Vector3.right * -currentHorizontalDistance);currentHorizontalDistance = 0;}}else{return;}}}
推荐整理分享跑酷角色左右移控制(跑酷角色左右移动怎么弄),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:跑酷左右上墙,跑酷左右上墙,跑酷左右跳墙,一个跑酷游戏左右滑动,一个跑酷游戏左右滑动,跑酷角色左右移动怎么弄,跑酷角色左右移动怎么弄,跑酷角色左右移动教程,内容如对您有帮助,希望把文章链接给更多的朋友!
摄像机跟随与摄像机晃动 usingUnityEngine;usingSystem.Collections;publicclassCameraFollows:MonoBehaviour{privateVector3position;publicTransformtarget;publicfloatdistance;publicfloattargetHeight;publicfloatPitchAngle;privatefl
当前动画的控制 //stateInfo.fullPathHash:判断当前动画状态;Animator.StringToHash(BaseLayer.Kick):获取kick动画的序列号;!anim.IsInTransition(0):触发的动画不是当前状态的动画时
控制角色jump //控制角色向上跳跃IEnumeratorJumpMove(){floatcurrentHeight=0;rig.useGravity=false;while(currentHeightjumpHeight){transform.position=Vector3.up*jumpPower*Time.deltaTime;currentHeight=jumpPower*