字幕列表 影片播放 列印所有字幕 列印翻譯字幕 列印英文字幕 Let's look at the basic joints in Unity. 接下來介紹Unity的基本關節系統(Joints) In this example we have fixed joints 在這個範例內包括了固定關節(Fixed Joint) 和彈簧關節(Spring Joint) and spring joints. 利用這兩種關節組成這樣的破壞鍊球 This example forms a basic wrecking ball 首先是固定關節 固定關節的原理很像階層裡的父子結構 that does this. 關節會將物件鎖在一個世界座標 或鎖在一個連結的剛體 Firstly the fixed joint. Fixed joints 範例中我們把第一個圓體物件放在天花板 然後加入一個固定關節 work in a similar way to parenting objects 這樣一來它就會被鎖定在該座標 in the hierarchy. 固定關節還可以設定斷裂力道(Break Force) 和斷裂扭力(Break Torque) The joint simply locks a game object 斷裂力道與斷裂扭力是破壞關節 所需要的最小力量 to the point in the world, or to a 當關節被破壞時 遊戲物件就可以再次自由移動 connected rigidbody. 鍊球其他的圓柱要設定彈簧關節 In this example we simply have placed the 彈簧關節的原理是 first capsule in the chain up near 關節會嘗試移動到目標座標 即物件在場景裡的座標 the ceiling and attached a fixed joint. 而物件的剛體會將關節用一個連在錨點 的隱形彈簧將物件拖離目標位置 This locks it in place. 如果彈簧關節有連結剛體 那它的目標座標 The other parameters of this fixed joint 會指向剛體所屬的遊戲物件 而不是一個世界座標 are Break Force and Break Torque. 舉例來說, 二號圓柱體的目標 This is the minimum amount of force required 是一號圓柱體,而三號圓柱體 to break the joint. 目標是二號圓柱體 When the joint is broken the game object 開始移動時它們不是往原來位置移動 而是往那些圓體物件的錨點移動 can once again move freely. 錨點(Anchor)是關節的支點 The other capsules in the chain have 是彈簧連接遊戲物件的位置 spring joints. Spring joints work on the 錨點在遊戲視圖內以橘色的圓點或方形來表示 principle that the game object is trying 彈性(Spring)參數代表彈簧的韌度 數值越高代表彈簧越緊或堅固 to reach a target position. The target 阻尼(Damper)設定關節動作放慢的速度 數值越高代表彈簧晃過頭的機會越小 position that it's trying to reach is the 最小距離(Min Distance)和最大距離(Max Distance) 設定彈簧活動的一個區域,用來限制彈簧長度 position that it's set to in the scene view 相同於固定關節 彈簧關節也有斷裂力道與斷裂扭力 and any rigid bodies that are attached to it 你可以設定這些力道 來指定斷裂彈簧所需要的最小數值 will pull it away from this position 最後是鉸鏈關節(Hinge Joints) on an invisible spring attached 鉸鏈關節適合用在門這類的物件 to the anchor point. 鉸鏈關節跟彈簧關節有些參數相似 它的軸向就是旋轉軸向 If the spring joint has a connected rigidbody 在這個範例裡 then the target point that the spring 我們在門加上了鉸鏈關節 然後將錨點設定在X軸的1 is trying to reach is relative to that 代表它的錨點從中心移到了邊緣 game object rather than to world space. 同樣的, Unity的關節是以橘色來表示 So for example, the second capsule here 你可以看到一條橘色的直線 而那就是鉸鏈關節的位置 is trying to reach capsule 1, and capsule 3 這裡的軸向(Axis)代表關節以哪個軸向為支點 is trying to reach capsule 2. 我們將支點設定到Y軸 這樣只要加上簡單的腳本它就會像是真的鉸鏈 As these move they will no longer be heading 腳本裡我們讓門被點擊後 加入往Z軸後推的力量 towards the original positions, rather 往後推的語法是 -transform.forward they will be heading towards the anchor 在AddForce的教學影片裡的範例 門的物件在加入力量後應該會飛出去 point of wherever those capsules happen to be. 但現在門的物件有了鉸鏈關節 The anchor is the pivot point of the joint. 當我我們對門施加力量 他就會以支點為軸心進行旋轉 You should consider it as where the spring is 所以不管我們對門施加幾次力量 它都不會壞掉 attached to the game object. 就像彈簧關節一樣 我們可以加入一些彈簧的特徵 This is shown in the scene view by 首先將使用彈簧選項(Use Spring)打勾 然後設定彈簧的彈性, 阻尼和目標位置即可 an orange dot or box. 有別於彈簧關節 The spring parameter is a measure of how 鉸鏈關節還有馬達(motor)和限制(limits)設定 strong the spring is. The higher the 馬達設定讓你的關節可以加上速度 就像旋轉門一樣 value the tighter or stronger the 目標速度(Target Velocity)設定關節的旋轉速度 spring becomes. The damper parameter 力道(Force)是要達到目標速度的值 is how much the joint will slow down 假如你勾選了自由選轉(Free Spin) 力道只會用來幫關節加速而不會減速 under motion. The higher the number, the 限制設定是用來限制關節的動態 比如一般的門 less the spring will overshoot. 最小(Min)與最大(Max) 是用來設定關節可以移動的旋轉角度 The min and max distances are for setting 最小回饋(Min Bounce)與最大回饋(Max Bounce) up a sort of dead zone for where the 用來設定當關節轉到限制角度時所作的反應 spring isn't active. They effectively restrict 跟其他關節一樣 鉸鏈關節也有斷裂力道與斷裂扭力 the length of the spring. 舉例來說, 如果我們在斷裂力道 設定了一個較低的值 Similar to the fixed joint, the spring 當我們在門上施加力量時 就會使鉸鏈關節斷裂 also has a break force and a break torque, 注意到門並非直接向後飛去 which you can set to a certain amount in order 而是從鉸鏈關節點被扯斷 to find the minimum force required to break that joint. Finally, Hinge Joints. Hinge joints are ideal for things like doors and share some properties with spring joints. The axis of the hinge is the one that it rotates around. In this example our physics door has the hinge joint attached. The anchor is set to 1 in the X axis, which moves it from it's center to it's edge. Again the joint is represented in orange in Unity and you can see a small line showing you where the hinge is currently located. The axis then allows us to specify around which axis the hinge will pivot. We've set this to the Y axis so it will react like a real hinge with a simple script we're applying a force to the door when we click on it, which pushes it backwards in it's Z axis using the shortcut minus transform.forward. In the Add Force lesson you may have seen that this fires the door straight out of the frame. But now that we have a hinge, when we apply the force to the door it simply pivots around that point. and no matter how many times we add force to it, it doesn't break. In a similar manner to our spring joint we can apply spring-like characterises by using the Use Spring checkbox and using the values underneath the spring settings. The other differences between hinge joints and spring joints are motors and limits. Motors are for introducing a velocity to your joint, for example a revolving door. The Target Velocity is the velocity the joint is trying to rotate at and the force is used to try and attain that velocity. If Free Spin is checked then the force will only be used to try and accelerate the joint and not to decelerate it. Limits can be used if you wish to constrain the motion of your joint, like with the normal door. The minimum and maximum are the angles between which the joint can move. Min and Max Bounce are the amount by which the joint will bounce when it reaches one of it's limits. And similar to our spring joint, yet again we have break forces and torques. For example, if we add in a reasonably low number into the break force property, we can break the door off of the hinge when adding a force. You should note that when doing this the door doesn't fly directly backwards but is instead pulled away from it's hinge.
B1 中級 中文 英國腔 關節 彈簧 鉸鏈 斷裂 物件 設定 接頭 - Unity官方教程 (Joints - Unity Official Tutorials) 121 5 朱瑛 發佈於 2021 年 01 月 14 日 更多分享 分享 收藏 回報 影片單字