Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
CharacterController 角色控制器
# CharacterController 角色控制器 Inherits from [Collider](../Collider/Collider.html) 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](http://www.unity3d.com/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**变量** * [isGrounded](CharacterController.isGrounded.html) Was the CharacterController touching the ground during the last move? 着地 在最后的移动角色控制器是否触碰地面? * [velocity](CharacterController.velocity.html) The current relative velocity of the Character (see notes). 角色当前的相对速度(参见注解)。 * [collisionFlags](CharacterController.collisionFlags.html) What part of the capsule collided with the environment during the last CharacterController.Move call. 在最后的 CharacterController.Move 调用期间,胶囊体的哪个部分与周围环境相碰撞。 * [radius](CharacterController.radius.html) The radius of the character's capsule 角色胶囊体的半径。 * [height](CharacterController.height.html) The height of the character's capsule 角色胶囊体的高度。 * [center](CharacterController.center.html) The center of the character's capsule relative to the transform's position. 相对于变换位置的角色胶囊体的中心 * [slopeLimit](CharacterController.slopeLimit.html) The character controllers slope limit in degrees 角色控制器的坡度度数限制。 * [stepOffset](CharacterController.stepOffset.html) The character controllers step offset in meters 以米为单位的角色控制器的台阶偏移量(台阶高度)。 * [detectCollisions](CharacterController.detectCollisions.html) Should other rigidbodies or character controllers collide with this character controller (By default always enabled) 其他的刚体和角色控制器是否能够与本角色控制器相碰撞(默认值通常是 enabled) ### Functions**函数** * [SimpleMove](CharacterController.SimpleMove.html) Moves the character with speed. 以一定的速度移动角色。 * [Move](CharacterController.Move.html) A more complex move function taking absolute movement deltas. 一个更加复杂的移动函数,每次都绝对移动。 ### Messages Sent**发送消息** * [OnControllerColliderHit](CharacterController.OnControllerColliderHit.html) OnControllerColliderHit is called when the controller hits a collider while performing a Move. 控制器碰撞器相碰 当控制器碰撞一个正在运动的碰撞器时,OnControllerColliderHit 被调用。 ## Inherited members**继承成员** ### Inherited Variables**继承变量** * [attachedRigidbody](../Collider/Collider.attachedRigidbody.html) The rigidbody the collider is attached to. 碰撞器附加的刚体。 * [isTrigger](../Collider/Collider.isTrigger.html) Is the collider a trigger? 碰撞器是一个触发器? (是否可以穿越) * [material](../Collider/Collider.material.html) The material used by the collider. 撞器使用的材质。 * [sharedMaterial](../Collider/Collider.sharedMaterial.html) The shared physic material of this collider. 碰撞器的共享物理材质。 * [bounds](../Collider/Collider.bounds.html) The world space bounding volume of the collider. 碰撞器在世界坐标空间的包围盒。 * [transform](../Component/Component.transform.html) The [Transform](../Transform/Transform.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Transform](../Transform/Transform.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [rigidbody](../Component/Component.rigidbody.html) The [Rigidbody](../Rigidbod/Rigidbody.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Rigidbody](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [camera](../Component/Component.camera.html) The [Camera](../Camera/Camera.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Camera](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [light](../Component/Component.light.html) The [Light](../Light/Light.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Light](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [animation](../Component/Component.animation.html) The [Animation](../Animation/Animation.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Animation](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [constantForce](../Component/Component.constantForce.html) The [ConstantForce](../ConstantForce/ConstantForce.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [ConstantForce](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [renderer](../Component/Component.renderer.html) The [Renderer](../Renderer/Renderer.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Renderer](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [audio](../Component/Component.audio.html) The [AudioSource](../AudioSource/AudioSource.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [AudioSource](../AudioSource/AudioSource.html)[](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [guiText](../Component/Component.guiText.html) The [GUIText](../GUIText/GUIText.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [GUIText](../GUIText/GUIText.html)[](../AudioSource/AudioSource.html)[](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [networkView](../Component/Component.networkView.html) The [NetworkView](../NetworkView/NetworkView.html) attached to this [GameObject](../GameObject/GameObject.html) (Read Only). (null if there is none attached) [NetworkView](../NetworkView/NetworkView.html)[](../GUIText/GUIText.html)[](../AudioSource/AudioSource.html)[](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](../Transform/Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(只读)(如无附加则为空)。 * [guiTexture](../Component/Component.guiTexture.html) The [GUITexture](../GUITexture/GUITexture.html) attached to this [GameObject](../GameObject/GameObject.html) (Read Only). (null if there is none attached) [GUITexture](../GUITexture/GUITexture.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(只读)(如无附加则为空)。 * [collider](../Component/Component.collider.html) The [Collider](../Collider/Collider.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Collider](../Collider/Collider.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [hingeJoint](../Component/Component.hingeJoint.html) The [HingeJoint](../HingeJoint/HingeJoint.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [HingeJoint](../HingeJoint/HingeJoint.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [particleEmitter](../Component/Component.particleEmitter.html) The [ParticleEmitter](../ParticleEmitter/ParticleEmitter.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [ParticleEmitter](../ParticleEmitter/ParticleEmitter.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [gameObject](../Component/Component.gameObject.html) The game object this component is attached to. A component is always attached to a game object. 组件附加的游戏物体。一个组件总是被附加到一个游戏物体。 * [tag](../Component/Component.tag.html) The tag of this game object. 游戏物体的标签。 * [name](../Object/Object.name.html) The name of the object. //物体的名字 * [hideFlags](../Object/Object.hideFlags.html) Should the object be hidden, saved with the scene or modifiable by the user? 物体是否被隐藏、保存在场景中或被用户修改? ### Inherited Functions**继承函数** * [ClosestPointOnBounds](../Collider/Collider.ClosestPointOnBounds.html) The closest point to the bounding box of the attached collider. 到附加碰撞器的包围盒最近的点。 * [Raycast](../Collider/Collider.Raycast.html) Casts a Ray that ignores all Colliders except this one. 投射一个光线([Ray](../Ray/Ray.html)),它忽略所有碰撞器,除了这个。 * [GetComponent](../Component/Component.GetComponent.html) Returns the component of Type type if the game object has one attached, null if it doesn't. 如果游戏物体有一个附加,则返回 Type 类型的组件,如果没有则为 null。 * [GetComponent.<T>](../Component/Component.GetComponent.ltTgt.html) * [GetComponent](../Component/Component.GetComponent.html) Returns the component with name type if the game object has one attached, null if it doesn't. 如果游戏物体有一个附加,则返回名字类型组件,如果没有则为 null。 * [GetComponentInChildren](../Component/Component.GetComponentInChildren.html) Returns the component of Type type in the [GameObject](../GameObject/GameObject.html) or any of its children using depth first search. 返回 Type 类型组件,在 [GameObject](../GameObject/GameObject.html) 或它的任何子物体使用深度优先搜索,仅返回激活的组件。 * [GetComponentInChildren.<T>](../Component/Component.GetComponentInChildren.ltTgt.html) * [GetComponentsInChildren](../Component/Component.GetComponentsInChildren.html) Returns all components of Type type in the [GameObject](../GameObject/GameObject.html) or any of its children. 在 [GameObject](../GameObject/GameObject.html) 或任何它的子物体,返回全部 Type 类型组件 * [GetComponentsInChildren.<T> ](../Component/Component.GetComponentsInChildren.ltTgt.html) * [GetComponents](../Component/Component.GetComponents.html) Returns all components of Type type in the [GameObject](../GameObject/GameObject.html). 在游戏物体返回全部 Type 类型组件。 * [GetComponents.<T> ](../Component/Component.GetComponents.ltTgt.html) * [CompareTag](../Component/Component.CompareTag.html) Is this game object tagged tag? 游戏物体有被标记标签么? * [SendMessageUpwards](../Component/Component.SendMessageUpwards.html) Calls the method named methodName on every [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) in this game object and on every ancestor of the behaviour 在游戏物体每一个 [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) 和每一个 behaviour 的祖先上调用名为 methodName 的方法。 * [SendMessage](../Component/Component.SendMessage.html) Calls the method named methodName on every [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) in this game object. 在游戏物体每一个 [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) 上调用名为 methodName 的方法。 * [BroadcastMessage](../Component/Component.BroadcastMessage.html) Calls the method named methodName on every [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) in this game object or any of its children. 在游戏物体每一个 [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) 和它的全部子物体上调用名为 methodName 的方法。 * [GetInstanceID](../Object/Object.GetInstanceID.html) Returns the instance id of the object. 返回物体的实例 ID * [ToString](../Object/Object.ToString.html) Returns the name of the game object. 返回游戏物体的名称。 ### Messages Sent**发送消息** * [OnTriggerEnter](../Collider/Collider.OnTriggerEnter.html) OnTriggerEnter is called when the Collider other enters the trigger. 当碰撞器 other 进入触发器时 OnTriggerEnter 被调用。 * [OnTriggerExit](../Collider/Collider.OnTriggerExit.html) OnTriggerExit is called when the Collider other has stopped touching the trigger. 当碰撞器 other 停止触动触发器时,OnTriggerExit 被调用。 * [OnTriggerStay](../Collider/Collider.OnTriggerStay.html) OnTriggerStay is called almost all the frames for every Collider other that is touching the trigger. 每个碰撞器 other 触动触发器,几乎在所有的帧 OnTriggerStay 被调用。 * [OnCollisionEnter](../Collider/Collider.OnCollisionEnter.html) OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider. 当 collider/rigidbody 开始触动另一个 rigidbody/collider 时 OnCollisionEnter 被调用。 * [OnCollisionExit](../Collider/Collider.OnCollisionExit.html) OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider. 当 collider/rigidbody 停止触动另一个 rigidbody/collider 时,OnCollisionExit 被调用。 * [OnCollisionStay](../Collider/Collider.OnCollisionStay.html) OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider. 每个 collider/rigidbody 触动 rigidbody/collider,将在每帧调用 OnCollisionStay。通俗的说, ### Inherited Class Functions**继承类函数** * [operator bool](../Object/Object.operator_bool.html) Does the object exist? 物体是否存在? * [Instantiate](../Object/Object.Instantiate.html) Clones the object original and returns the clone. 克隆原始物体,并返回克隆的物体 * [Instantiate.<T>](../Object/Object.Instantiate.ltTgt.html) * [Destroy](../Object/Object.Destroy.html) Removes a gameobject, component or asset. 删除一个游戏物体、组件或资源 * [DestroyImmediate](../Object/Object.DestroyImmediate.html) Destroys the object obj immediately. It is strongly recommended to use Destroy instead. 立即销毁物体 obj,强烈建议使用 Destroy 代替。 * [FindObjectsOfType](../Object/Object.FindObjectsOfType.html) Returns a list of all active loaded objects of Type type. 返回 Type 类型的所有激活的加载的物体列表 * [FindObjectOfType](../Object/Object.FindObjectOfType.html) Returns the first active loaded object of Type type. 返回 Type 类型第一个激活的加载的物体。 * [operator ==](../Object/Object.operator_eq.html) Compares if two objects refer to the same 比较如果两个物体相同 * [operator !=](../Object/Object.operator_ne.html) Compares if two objects refer to a different object 比较如果两个物体不同 * [DontDestroyOnLoad](../Object/Object.DontDestroyOnLoad.html) Makes the object target not be destroyed automatically when loading a new scene. 加载新场景的时候使目标物体不被自动销毁。
da
2022年5月17日 17:27
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码