通常,所有类人角色都使用角色控制器 (Character Controller) 来实现。 角色控制器 (Character Controller) 本质上是非物理性的,如果要将真实物理现象应用于角色,比如在绳索上摇摆、由大岩石推动,则必须使用刚体 (Rigidbody),这样才能对角色使用关节 (Joint) 和力。 角色控制器 (Character Controller) 始终沿 Y 轴对...
public CharacterController2D cc;//角色控制器组件 public Animator animator;//动画控制器组件 public float speed = 5f;//速度 float move;//水平移动方向 bool jump;//是否跳跃 // Update is called once per frame void Update() { move = Input.GetAxis("Horizontal")*speed;//获取角色水平移动速度 ani...
地址:https://github.com/prime31/CharacterController2D 博主使用这个控制器的主要目的是为了做一款平台动作类游戏,因此也会着重说一些制作使用途中遇到的问题以及解决方法。 先看一下组件挂载在GameObject上之后可以设定的属性: 可以看到这里和CharacterController一样也有Skin Width这个选项,这个选项会影响角色控制器检测碰...
usingUnityEngine;publicclassCharacterController2D:MonoBehaviour{publicfloatspeed=5f;publicfloatjumpForce=5f;publicTransformgroundCheck;publicLayerMaskgroundLayer;privateRigidbody2Drb;privateboolisGrounded;privatefloatgroundCheckRadius=0.2f;voidStart(){rb=GetComponent<Rigidbody2D>();}voidUpdate(){// 检测角色是否...
首先需要先实现炸弹包和医药包的组合物体,实现下落和着落两个动画效果。 炸弹包 下落动画为实现物体左右摆动的效果,着陆动画为降落伞收起的效果,这个通过Scale来实现,使用land参数来控制两个动画的切换。 组合的父对象添加刚体使其具有重力的效果。 炸弹添加了两个脚本,BombPickup.cs控制炸弹包碰撞的逻辑(被捡起),Bom...
usingUnityEngine;publicclassCharacterController2D:MonoBehaviour{publicfloatmoveSpeed=5f;publicLayerMaskgroundLayer;privateVector2colliderOffset;privateRigidbody2Drb2D;privatevoidStart(){rb2D=GetComponent<Rigidbody2D>();colliderOffset=GetComponent<BoxCollider2D>().offset;}privatevoidMove(floatvelocity){floathorizont...
移动方法用很多种,比如调用人物的rigidbody2d的AddForce,方法给人物一个加速度等。 这里的方法是,先确定角色的位置,和将要到达的位置,然后在通过Rigidbody2D.MovePosition方法移动。 先提炼下代码。 publicclassCharacterController2D:MonoBehaviour{Rigidbody2Dm_Rigidbody2D;Vector2m_PreviousPosition;Vector2m_CurrentPositio...
2D Character - Clown (not enough ratings) $14.99 Lootzifr 2D Character - Buddha (not enough ratings) $14.99 Lootzifr 2D Character - Squirrel (not enough ratings) $14.99 Lootzifr 2D Character - Hillbilly (not enough ratings) $14.99
2D Character Controller Here is a free to use Character Controller for 2D platformer games in Unity. Currently the Controller features: Smooth movement Jumping Crouching Events for setting up animation 2D Physics To learn how to use it check out our video on 2D Movement which can be found on ...
WheelJoint2D WindZone WWW WWWAudioExtensions WWWForm YieldInstruction Interfaces Enumerations Attributes OtherCharacterControllerclass in UnityEngine/継承:Collider説明 CharacterController は Rigidbdy による処理を持たなくても衝突判定によって簡単に動きの制限を行うことが可能です。A...