CharacterController 角色控制器
Inherits from Collider
A CharacterController allows you to easily do movement constrained by collisions without having to deal with a rigidbody.
角色控制器允许你在受制于碰撞的情况下很容易的进行运动,而不用处理刚体。
(个人理解:用CharacterController组件,它包含Rigidbody组件的一些属性,就不用用Rigidbody组件了)。
A CharacterController is not affected by forces and will only move when you call the Move funtion. It will then carry out the movement but be constrained by collisions.
角色控制器不受力的影响,仅仅当你调用Move函数时才运动。然后它将执行运动,但是受制于碰撞。
参考:Character animation examples
摘自网络的Physx参考:
character一般用于主角这类用户控制的物体,它不会受到scene的重力影响,不会被其他物体推。
程序中可以使用它的move方法移动它,当他碰到静态物体时,会停下来,遇到动态物体时会推开他,当然,这些都是可以通过activegroup来控制的。group最多有32组。因为他是一个NxU32,并通过每一位代表一个组。
move的一个参数用来告诉程序,character的当前状态。(collisionFlags)
当他遇到物体的时候,如果设置了回调函数,系统会通过回调函数通知程序。。(NxControllerDesc.callback)
character还有上楼梯模式,在某些高度的台阶,可以直接上去。(NxControllerDesc.stepOffset)
character还可以设置可以走上去的斜坡。(NxControllerDesc.slopeLimit)
由于character不受场景的重力影响,所以,用户要在move函数中自己添加重力因素,也就是说,character可以浮在空中,除非那里有其他activegroup物体。
Variables变量
- isGroundedWas the CharacterController touching the ground during the last move?
着地 在最后的移动角色控制器是否触碰地面? - velocityThe current relative velocity of the Character (see notes).
角色当前的相对速度(参见注解)。 - collisionFlagsWhat part of the capsule collided with the environment during the last CharacterController.Move call.
在最后的CharacterController.Move调用期间,胶囊体的哪个部分与周围环境相碰撞。 - radiusThe radius of the character's capsule
角色胶囊体的半径。 - heightThe height of the character's capsule
角色胶囊体的高度。 - centerThe center of the character's capsule relative to the transform's position.
相对于变换位置的角色胶囊体的中心 - slopeLimitThe character controllers slope limit in degrees
角色控制器的坡度度数限制。 - stepOffsetThe character controllers step offset in meters
以米为单位的角色控制器的台阶偏移量(台阶高度)。 - detectCollisionsShould other rigidbodies or character controllers collide with this character controller (By default always enabled)
其他的刚体和角色控制器是否能够与本角色控制器相碰撞(默认值通常是enabled)
Functions函数
- SimpleMoveMoves the character with speed.
以一定的速度移动角色。 - MoveA more complex move function taking absolute movement deltas.
一个更加复杂的移动函数,每次都绝对移动。
Messages Sent发送消息
- OnControllerColliderHitOnControllerColliderHit is called when the controller hits a collider while performing a Move.
控制器碰撞器相碰 当控制器碰撞一个正在运动的碰撞器时,OnControllerColliderHit 被调用。
Inherited members继承成员Inherited Variables继承变量
- enabledEnabled Colliders will collide with other colliders, disabled Colliders won't.
启用碰撞器将会碰撞其他碰撞器,禁用碰撞器就不会碰撞其他碰撞器。 - attachedRigidbodyThe rigidbody the collider is attached to.
碰撞器附加的刚体。 - isTriggerIs the collider a trigger?
碰撞器是一个触发器? (是否可以穿越) - materialThe material used by the collider.
撞器使用的材质。 - sharedMaterialThe shared physic material of this collider.
碰撞器的共享物理材质。 - boundsThe world space bounding volume of the collider.
碰撞器在世界坐标空间的边界框。
- transformThe Transform attached to this GameObject (null if there is none attached).
Transform附加到GameObject(游戏物体)(如无附加则为空)。 - rigidbodyThe Rigidbody attached to this GameObject (null if there is none attached).
Rigidbody附加到GameObject(游戏物体)(如无附加则为空)。 - cameraThe Camera attached to this GameObject (null if there is none attached).
Camera附加到GameObject(游戏物体)(如无附加则为空)。 - lightThe Light attached to this GameObject (null if there is none attached).
Light附加到GameObject(游戏物体)(如无附加则为空)。 - animationThe Animation attached to this GameObject (null if there is none attached).
Animation附加到GameObject(游戏物体)(如无附加则为空)。 - constantForceThe ConstantForce attached to this GameObject (null if there is none attached).
ConstantForce附加到GameObject(游戏物体)(如无附加则为空)。 - rendererThe Renderer attached to this GameObject (null if there is none attached).
Renderer附加到GameObject(游戏物体)(如无附加则为空)。 - audioThe AudioSource attached to this GameObject (null if there is none attached).
AudioSource附加到GameObject(游戏物体)(如无附加则为空)。 - guiTextThe GUIText attached to this GameObject (null if there is none attached).
GUIText附加到GameObject(游戏物体)(如无附加则为空)。 - networkViewThe NetworkView attached to this GameObject (Read Only). (null if there is none attached)
NetworkView附加到GameObject(游戏物体)(只读)(如无附加则为空)。 - guiTextureThe GUITexture attached to this GameObject (Read Only). (null if there is none attached)
GUITexture附加到GameObject(游戏物体)(只读)(如无附加则为空)。 - colliderThe Collider attached to this GameObject (null if there is none attached).
Collider附加到GameObject(游戏物体)(如无附加则为空)。 - hingeJointThe HingeJoint attached to this GameObject (null if there is none attached).
HingeJoint附加到GameObject(游戏物体)(如无附加则为空)。 - particleEmitterThe ParticleEmitter attached to this GameObject (null if there is none attached).
ParticleEmitter附加到GameObject(游戏物体)(如无附加则为空)。 - gameObjectThe game object this component is attached to. A component is always attached to a game object.
组件附加的游戏物体。一个组件总是被附加到一个游戏物体。 - tagThe tag of this game object.
游戏物体的标签。
- nameThe name of the object. //物体的名字
- hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
物体是否被隐藏、保存在场景中或被用户修改?
Inherited Functions继承函数
- ClosestPointOnBoundsThe closest point to the bounding box of the attached collider.
到附加碰撞器的边界框最近的点。 - RaycastCasts a Ray that ignores all Colliders except this one.
投射一个光线(Ray),它忽略所有碰撞器,除了这个。
- GetComponentReturns the component of Type type if the game object has one attached, null if it doesn't.
如果游戏物体有一个附加,则返回Type类型的组件,如果没有则为null。 - GetComponent.<T>
- GetComponentReturns the component with name type if the game object has one attached, null if it doesn't.
如果游戏物体有一个附加,则返回名字类型组件,如果没有则为null。 - GetComponentInChildrenReturns the component of Type type in the GameObject or any of its children using depth first search.
返回Type类型组件,在GameObject或它的任何子物体使用深度优先搜索,仅返回激活的组件。 - GetComponentInChildren.<T>
- GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children.
在GameObject或任何它的子物体,返回全部Type类型组件 - GetComponentsInChildren.<T>
- GetComponentsReturns all components of Type type in the GameObject.
在游戏物体返回全部Type类型组件。 - GetComponents.<T>
- CompareTagIs this game object tagged tag?
游戏物体有被标记标签么? - SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour
在游戏物体每一个MonoBehaviour和每一个behaviour的祖先上调用名为methodName的方法。 - SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
在游戏物体每一个MonoBehaviour上调用名为methodName的方法。 - BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
在游戏物体每一个MonoBehaviour和它的全部子物体上调用名为methodName的方法。
- GetInstanceIDReturns the instance id of the object.
返回物体的实例ID - ToStringReturns the name of the game object.
返回游戏物体的名称。
Messages Sent发送消息
- OnTriggerEnterOnTriggerEnter is called when the Collider other enters the trigger.
当碰撞器other进入触发器时OnTriggerEnter被调用。 - OnTriggerExitOnTriggerExit is called when the Collider other has stopped touching the trigger.
当碰撞器other停止触动触发器时,OnTriggerExit被调用。 - OnTriggerStayOnTriggerStay is called almost all the frames for every Collider other that is touching the trigger.
每个碰撞器other触动触发器,几乎在所有的帧OnTriggerStay被调用。 - OnCollisionEnterOnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.
当collider/rigidbody开始触动另一个rigidbody/collider时OnCollisionEnter被调用。 - OnCollisionExitOnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider.
当 collider/rigidbody停止触动另一个 rigidbody/collider时,OnCollisionExit被调用。 - OnCollisionStayOnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.
每个collider/rigidbody触动rigidbody/collider,将在每帧调用OnCollisionStay。通俗的说,
Inherited Class Functions继承类函数
- DestroyRemoves a gameobject, component or asset.
删除一个游戏物体、组件或资源 - DestroyImmediateDestroys the object obj immediately. It is strongly recommended to use Destroy instead.
立即销毁物体obj,强烈建议使用Destroy代替。 - DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
加载新场景的时候使目标物体不被自动销毁。 - FindObjectOfTypeReturns the first active loaded object of Type type.
返回Type类型第一个激活的加载的物体。 - FindObjectsOfTypeReturns a list of all active loaded objects of Type type.
返回Type类型的所有激活的加载的物体列表 - InstantiateClones the object original and returns the clone.
克隆原始物体,并返回克隆的物体