找回密碼
 注冊帳號

掃一掃,訪問微社區

charactercontroller 角色控制器

2015-1-4 10:47| 發布者: 楊炎| 查看: 2515| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: charactercontroller 角色控制器inherits fromcollidera charactercontroller allows you to easily do movement constrained by collisions without having to deal with a rigidbody.角色控制器允許你在受制于碰撞 ...

charactercontroller 角色控制器

inherits fromcollider

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變量

isgrounded

was the charactercontroller touching the ground during the last move?

著地 在最后的移動角色控制器是否觸碰地面?

velocity

the current relative velocity of the character (see notes).

角色當前的相對速度(參見注解)。

collisionflags

what part of the capsule collided with the environment during the last charactercontroller.move call.

在最后的charactercontroller.move調用期間,膠囊體的哪個部分與周圍環境相碰撞。

radius

the radius of the character's capsule

角色膠囊體的半徑。

height

the height of the character's capsule

角色膠囊體的高度。

center

the center of the character's capsule relative to the transform's position.

相對于變換位置的角色膠囊體的中心

slopelimit

the character controllers slope limit in degrees

角色控制器的坡度度數限制。

stepoffset

the character controllers step offset in meters

以米為單位的角色控制器的臺階偏移量(臺階高度)。

detectcollisions

should other rigidbodies or character controllers collide with this character controller (by default always enabled)

其他的剛體和角色控制器是否能夠與本角色控制器相碰撞(默認值通常是enabled)

functions函數

simplemove

moves the character with speed.

以一定的速度移動角色。

move

a more complex move function taking absolute movement deltas.

一個更加復雜的移動函數,每次都絕對移動。

messages sent發送消息

oncontrollercolliderhit

oncontrollercolliderhit is called when the controller hits a collider while performing a move.

控制器碰撞器相碰 當控制器碰撞一個正在運動的碰撞器時,oncontrollercolliderhit 被調用。

inherited members繼承成員

inherited variables繼承變量

enabled

enabled colliders will collide with other colliders, disabled colliders won't.

啟用碰撞器將會碰撞其他碰撞器,禁用碰撞器就不會碰撞其他碰撞器。

attachedrigidbody

the rigidbody the collider is attached to.

碰撞器附加的剛體。

istrigger

is the collider a trigger?

碰撞器是一個觸發器? (是否可以穿越)

material

the material used by the collider.

撞器使用的材質。

sharedmaterial

the shared physic material of this collider.

碰撞器的共享物理材質。

bounds

the world space bounding volume of the collider.

碰撞器在世界坐標空間的邊界框。

transform

thetransformattached to thisgameobject(null if there is none attached).

transform附加到gameobject(游戲物體)(如無附加則為空)。

rigidbody

therigidbodyattached to thisgameobject(null if there is none attached).

rigidbody附加到gameobject(游戲物體)(如無附加則為空)。

camera

thecameraattached to thisgameobject(null if there is none attached).

camera附加到gameobject(游戲物體)(如無附加則為空)。

light

thelightattached to thisgameobject(null if there is none attached).

light附加到gameobject(游戲物體)(如無附加則為空)。

animation

theanimationattached to thisgameobject(null if there is none attached).

animation附加到gameobject(游戲物體)(如無附加則為空)。

constantforce

theconstantforceattached to thisgameobject(null if there is none attached).

constantforce附加到gameobject(游戲物體)(如無附加則為空)。

renderer

therendererattached to thisgameobject(null if there is none attached).

renderer附加到gameobject(游戲物體)(如無附加則為空)。

audio

theaudiosourceattached to thisgameobject(null if there is none attached).

audiosource附加到gameobject(游戲物體)(如無附加則為空)。

guitext

theguitextattached to thisgameobject(null if there is none attached).

guitext附加到gameobject(游戲物體)(如無附加則為空)。

networkview

thenetworkviewattached to thisgameobject(read only). (null if there is none attached)

networkview附加到gameobject(游戲物體)(只讀)(如無附加則為空)。

guitexture

theguitextureattached to thisgameobject(read only). (null if there is none attached)

guitexture附加到gameobject(游戲物體)(只讀)(如無附加則為空)。

collider

thecolliderattached to thisgameobject(null if there is none attached).

collider附加到gameobject(游戲物體)(如無附加則為空)。

hingejoint

thehingejointattached to thisgameobject(null if there is none attached).

hingejoint附加到gameobject(游戲物體)(如無附加則為空)。

particleemitter

theparticleemitterattached to thisgameobject(null if there is none attached).

particleemitter附加到gameobject(游戲物體)(如無附加則為空)。

gameobject

the game object this component is attached to. a component is always attached to a game object.

組件附加的游戲物體。一個組件總是被附加到一個游戲物體。

tag

the tag of this game object.

游戲物體的標簽。

name

the name of the object. //物體的名字

hideflags

should the object be hidden, saved with the scene or modifiable by the user?

物體是否被隱藏、保存在場景中或被用戶修改?

inherited functions繼承函數

closestpointonbounds

the closest point to the bounding box of the attached collider.

到附加碰撞器的邊界框最近的點。

raycast

casts a ray that ignores all colliders except this one.

投射一個光線(ray),它忽略所有碰撞器,除了這個。

相關閱讀

文章點評
相關文章
女校游泳队彩金