包含11節(jié)視頻教程
從零基礎(chǔ)學(xué)習(xí)unity3d游戲引擎,簡單易學(xué)的視頻教程,讓你快速掌握unity3d,并喜歡上游戲開發(fā)的樂趣。
|
角色控制器主要用于第三人稱或第一人稱游戲主角控制,并不使用剛體物理效果。
Properties 屬性
Details 細節(jié)The traditional Doom-style first person controls are not physically realistic. The character runs 90 miles per hour, comes to a halt immediately and turns on a dime. Because it is so unrealistic, use of Rigidbodies and physics to create this behavior is impractical and will feel wrong. The solution is the specialized Character Controller. It is simply a capsule shaped Collider which can be told to move in some direction from a script. The Controller will then carry out the movement but be constrained by collisions. It will slide along walls, walk up stairs (if they are lower than the Step Offset) and walk on slopes within the Slope Limit. 傳統(tǒng)的"毀滅戰(zhàn)士"風(fēng)格的第一人稱控制并未依據(jù)物理現(xiàn)實。角色跑到了90英里每小時,然后馬上停下而且可以極快的轉(zhuǎn)身。因為是這么地不真實,用剛體和物理效果來創(chuàng)建這種行為是不切實際的,感覺上也不對勁。解決辦法就是專門的角色控制器。很簡單,就是一個膠囊碰撞器附加了可以控制其移動的腳本?刂破鲿䦂(zhí)行腳本傳達的動作但被碰撞影響。它會沿著墻動,走上臺階(如果臺階高度低于Step Offset屬性)以及走上坡度小于Slope Limit的斜坡。 The Controller does not react to forces on its own and it does not automatically push Rigidbodies away. 控制器不會對加在它自身上的力做出反應(yīng),也不會自動推開其他剛體。 If you want to push Rigidbodies or objects with the Character Controller, you can apply forces to any object that it collides with via the OnControllerColliderHit() function through scripting. 如果想讓角色控制器推開其他剛體或者對象,你可以在對象附加的腳本中添加OnControllerColliderHit()函數(shù),這樣對它們施加力就能夠產(chǎn)生碰撞。 On the other hand, if you want your player character to be affected by physics then you might be better off using a Rigidbody instead of the Character Controller. 另外,如果你想讓你的游戲角色被物理效果影響,那就最好使用剛體而不是角色控制器。 Fine-tuning your character 仔細調(diào)整你的角色You can modify the Height and Radius to fit your Character's mesh. It is recommended to always use around 2 meters for a human-like character. You can also modify the Center of the capsule in case your pivot point is not at the exact center of the Character. 你可以修改Height 和Radius的大小來使控制器和你的角色網(wǎng)格匹配。對于人形的角色一直推薦使用大約2米。同樣可以修改膠囊的Center屬性來使轉(zhuǎn)動中心和角色的中心吻合。 Step Offset can affect this too, make sure that this value is between 0.1 and 0.4 for a 2 meter sized human. Step Offset屬性也會影響角色,確保對于一個兩米大小的人來說該值介于0.1到0.4之間。 Slope Limit should not be too small. Often using a value of 90 degrees works best. The Character Controller will not be able to climb up walls due to the capsule shape. Slope Limit不能設(shè)的太小,一般使用90度會比較合適。由于是膠囊體,角色控制器不會爬上墻。 Don't get stuck 不要被卡住The Skin Width is one of the most critical properties to get right when tuning your Character Controller. If your character gets stuck it is most likely because your Skin Width is too small. The Skin Width will let objects slightly penetrate the Controller but it removes jitter and prevents it from getting stuck. Skin Width是調(diào)整你的角色控制器時最難正確設(shè)置的邊界值之一。如果你的角色被卡住了,那最有可能就是因為該值設(shè)的太小。Skin Width會讓其他物體有少許穿透控制器但是能夠避免震顫以及阻止被卡住。 It's good practice to keep your Skin Width at least greater than 0.01 and more than 10% of the Radius. 實踐中比較好的值是至少要大于0.01并且大于Radius的10%。 We recommend keeping Min Move Distance at 0. 推薦把Min Move Distance設(shè)為0. See the Character Controller script reference here 點擊此處查看角色控制器的腳本參考。 You can download an example project showing pre-setup animated and moving character controllers from the Resources area on our website. 可以從我們網(wǎng)站的Resources處下載示例工程,演示了預(yù)設(shè)值的可以活動和移動的角色控制器。 Hints 提示
贊0 踩0 |
未知用戶
2005-2025 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號-1
2005-2025 ZhuFeng Community All Rights Reserved
VIP