朱峰社區(qū)首頁(yè) 朱峰社區(qū)

搜索資源 注冊(cè)|登陸

等待

返回 展開(kāi)菜單
按功能 按軟件

繪制真實(shí)照片

繪制真實(shí)照片

包含9節(jié)視頻教程

這是臨摹的終極表現(xiàn)!在臨摹領(lǐng)域達(dá)到真實(shí)照片的級(jí)別,讓你的繪畫(huà)讓別人驚呼吧!這不是照片,真的是繪畫(huà)出來(lái)的。我們一起來(lái)學(xué)習(xí)吧!

關(guān)閉

Unity組件:Box Collider 盒碰撞器

關(guān)注:3154 留言:0 樓主:zhoujunmss001 發(fā)帖時(shí)間:15年11月16日

zhoujunmss001

普通會(huì)員

zhoujunmss001

社區(qū)新人:1級(jí)

關(guān)注3386人

  • 性別

  • 年齡

    23

  • 積分

    1

  • 登陸

    1

  • 發(fā)帖

    1

  • 作品

    1

間隔線

The Box Collider is a basic cube-shaped collision primitive.

盒碰撞器是一個(gè)基本的方形碰撞原型。

盒碰撞器 Box Collider
A pile of Box Colliders 一堆盒碰撞器

Properties 屬性
  • Material 材質(zhì)
    Reference to the Physic Material that determines how this Collider interacts with others.
    引用何種物理材質(zhì)決定了他和其他對(duì)象如何作用。
  • Is Trigger 是否觸發(fā)器
    If enabled, this Collider is used for triggering events, and is ignored by the physics engine.
    如激活,此碰撞器用于觸發(fā)事件,并且被物理引擎忽略。
  • Size 大小
    The size of the Collider in the X, Y, Z directions.
    在X、Y、Z三維上的碰撞器尺寸。
  • Center 中心
    The position of the Collider in the object's local space.
    碰撞器在對(duì)象本地坐標(biāo)中的位置
Details 細(xì)節(jié)

The Box Collider can be resized into different shapes of rectangular prisms. It works great for doors, walls, platforms, etc. It is also effective as a human torso in a ragdoll or as a car hull in a vehicle. Of course, it works perfectly for just boxes and crates as well!

盒碰撞器可以被調(diào)整成不同大小的長(zhǎng)方體。能夠很好地用于門(mén)、墻、平臺(tái)等等。也能夠用于角色的軀干或者車輛等交通工具的外殼。當(dāng)然,只是用在盒子或者箱子上表現(xiàn)也十分完美。

A standard Box Collider 一個(gè)標(biāo)準(zhǔn)的盒碰撞器
A standard Box Collider 一個(gè)標(biāo)準(zhǔn)的盒碰撞器

Colliders work with Rigidbodies to bring physics in Unity to life. Whereas Rigidbodies allow objects to be controlled by physics, Colliders allow objects to collide with each other. Colliders must be added to objects independently of Rigidbodies. A Collider does not necessarily need a Rigidbody attached, but a Rigidbody must be attached in order for the object to move as a result of collisions.

盒碰撞器作用于剛體使Unity中的物理作用生效。因?yàn)閯傮w允許對(duì)象被物理系統(tǒng)控制。碰撞器使對(duì)象之間產(chǎn)生碰撞作用。碰撞器必須獨(dú)立于剛體加在對(duì)象上。碰撞器并不一定需要附加剛體,但是要使移動(dòng)物體具有碰撞效果必須附加剛體。

When a collision between two Colliders occurs and if at least one of them has a Rigidbody attached, three collision messages are sent out to the objects attached to them. These events can be handled in scripting, and allow you to create unique behaviors with or without making use of the built-in NVIDIA PhysX engine.

當(dāng)兩個(gè)碰撞器間產(chǎn)生碰撞并且其中至少一個(gè)附加了剛體時(shí),三個(gè)碰撞信息會(huì)發(fā)送給附加他們的對(duì)象,這些事件可以被腳本處理,而且允許用戶可以選擇自己寫(xiě)腳本或使用內(nèi)置的NVIDIA PhysX引擎創(chuàng)建唯一的行為。

Triggers 觸發(fā)器

An alternative way of using Colliders is to mark them as a Trigger, just check the IsTrigger property checkbox in the Inspector. Triggers are effectively ignored by the physics engine, and have a unique set of three trigger messages that are sent out when a collision with a Trigger occurs. Triggers are useful for triggering other events in your game, like cutscenes, automatic door opening, displaying tutorial messages, etc. Use your imagination!

一個(gè)可供選擇的碰撞器使用方法是標(biāo)記他們?yōu)橛|發(fā)器,僅需要選中檢視面板中的IsTrigger屬性選擇框。觸發(fā)器不受物理引擎控制,當(dāng)和一個(gè)觸發(fā)器發(fā)生碰撞時(shí)會(huì)發(fā)出三個(gè)獨(dú)特的觸發(fā)信息。觸發(fā)器用于觸發(fā)你游戲中的其他事件,比如過(guò)場(chǎng)動(dòng)畫(huà)、自動(dòng)門(mén)開(kāi)啟、顯示教程信息等等,發(fā)揮你的想象力吧!

Be aware that in order for two Triggers to send out trigger events when they collide, one of them must include a Rigidbody as well. For a Trigger to collide with a normal Collider, one of them must have a Rigidbody attached. For a detailed chart of different types of collisions, see the collision action matrix in the Advanced section below.

當(dāng)然也應(yīng)該意識(shí)到為了使兩個(gè)觸發(fā)器碰撞時(shí)發(fā)出碰撞事件,其中一個(gè)必須包含剛體。一個(gè)觸發(fā)器和一個(gè)普通碰撞器碰撞,其中之一必須附加剛體。想了解不同類型碰撞的詳細(xì)情況,可以參考下邊進(jìn)階部分中的碰撞行為矩陣。

Friction and bouncyness 摩擦力和彈力

Friction, bouncyness and softness are defined in the Physic Material. The Standard Assets contain the most common physics materials. To use one of them click on the Physic Material drop-down and select one, eg. Ice. You can also create your own physics materials and tweak all friction values.

摩擦力、彈力和柔軟度由物理材質(zhì)中定義。標(biāo)準(zhǔn)資源( Standard Assets)中包含了大部分常見(jiàn)的物理材質(zhì)。要使用只需點(diǎn)擊物理材質(zhì)上的下拉箭頭然后選中一個(gè),比如冰。你也可以創(chuàng)建你自己的物理材質(zhì)并調(diào)整摩擦力的大小。

Compound Colliders 復(fù)合碰撞器

Compound Colliders are combinations of primitive Colliders, collectively acting as a single Collider. They come in handy when you have a complex mesh to use in collisions but cannot use a Mesh Collider. To create a Compound Collider, create child objects of your colliding object, then add a primitive Collider to each child object. This allows you to position, rotate, and scale each Collider easily and independently of one another.

復(fù)合碰撞器是組合原型碰撞器,共同扮演單個(gè)碰撞器的角色。當(dāng)你在碰撞器上使用了一組復(fù)雜的網(wǎng)格而網(wǎng)格碰撞器不能用時(shí),這是很好的選擇。要?jiǎng)?chuàng)建復(fù)合碰撞器,只需給你的碰撞器對(duì)象創(chuàng)建子對(duì)象,然后為每個(gè)子對(duì)象添加原型碰撞器。這就允許你輕易地移動(dòng)、旋轉(zhuǎn)或者伸縮每個(gè)碰撞器,并使他們互相之間互不影響。

一個(gè)真實(shí)復(fù)合碰撞器設(shè)置
A real-world Compound Collider setup 一個(gè)真實(shí)復(fù)合碰撞器設(shè)置

In the above picture, the environment has a Mesh Collider attached. Mesh Colliders work the best for terrain or environments made from irregular shapes. The gun_model GameObject has a Rigidbody attached, and multiple primitive Colliders as child GameObjects. When the Rigidbody parent is moved around by forces, the child Colliders move along with it. The primitive Colliders will collide with the environment's Mesh Collider, and the parent Rigidbody will alter the way it moves based on forces being applied to it and how its child Colliders interact with other Colliders in the Scene.

上圖中,環(huán)境附加了一個(gè)網(wǎng)格碰撞器。網(wǎng)格碰撞器用于由不規(guī)則形狀構(gòu)成的地形或環(huán)境十分合適。槍模型游戲?qū)ο蟾郊恿藙傮w和多個(gè)原型碰撞器子對(duì)象。當(dāng)父級(jí)剛體受力移動(dòng)時(shí),子級(jí)碰撞器也隨之一起移動(dòng)。原型碰撞器會(huì)和環(huán)境網(wǎng)格碰撞器碰撞,同時(shí)父級(jí)剛體會(huì)因子級(jí)碰撞器和場(chǎng)景中其他碰撞器作用產(chǎn)生的力改變移動(dòng)路徑。

Mesh Colliders can't normally collide with each other. If a Mesh Collider is marked as Convex, then it can collide with another Mesh Collider. The typical solution is to use primitive Colliders for any objects that move, and Mesh Colliders for static background objects.

網(wǎng)格碰撞器通常無(wú)法互相碰撞,如果一個(gè)網(wǎng)格碰撞器標(biāo)記為凸起的(Convex),那么它可以和其他碰撞器碰撞。典型的解決方法是在移動(dòng)對(duì)象上使用原型碰撞器而在靜態(tài)的背景對(duì)象上使用網(wǎng)格碰撞器。

Hints 提示
  • To add multiple Colliders for an object, create child GameObjects and attach a Collider to each one. This allows each Collider to be manipulated independently.
    要給一個(gè)對(duì)象添加多個(gè)碰撞器,應(yīng)該創(chuàng)建子對(duì)象并給每個(gè)子對(duì)象添加一個(gè)碰撞器。這使每個(gè)碰撞器可以被單獨(dú)操作。
  • You can look at the gizmos in the Scene View to see how the Collider is being calculated on your object.
    可以通過(guò)場(chǎng)景視圖(Scene View )中的線框(gizmos)來(lái)查看碰撞器在你的對(duì)象上的預(yù)期效果。
  • Colliders do their best to match the scale of an object. If you have a non-uniform scale (a scale which is different in each direction), only the Mesh Collider can match completely.
    碰撞器盡量匹配對(duì)象的比例。如果有一組不規(guī)則伸縮(每一維度上的比例都不相同),只能使用網(wǎng)格碰撞器才能完全匹配。
  • If you are moving an object through its Transform component but you want to receive Collision/Trigger messages, you must attach a Rigidbody to the object that is moving.
    如果你想接收通過(guò)Transform組件移動(dòng)的對(duì)象的碰撞/觸發(fā)信息,你必須給移動(dòng)對(duì)象附件剛體。
Advanced 進(jìn)階
Collider combinations 碰撞器組合

There are numerous different combinations of collisions that can happen in Unity. Each game is unique, and different combinations may work better for different types of games. If you're using physics in your game, it will be very helpful to understand the different basic Collider types, their common uses, and how they interact with other types of objects.

Unity中有許多不同的碰撞組合。每個(gè)游戲都很獨(dú)特,不同的組合可能更好地適用于不同類型的游戲。如果你在游戲中使用了物理效果,那理解不同的基本碰撞類型會(huì)很有幫助,包括它們的常用形式及如何和其他類型的對(duì)象作用。

Static Collider 靜態(tài)碰撞器

These are GameObjects that do not have a Rigidbody attached, but do have a Collider attached. These objects should remain still, or move very little. These work great for your environment geometry. They will not move if a Rigidbody collides with them.

指的是沒(méi)有附加剛體而附加了碰撞器的游戲?qū)ο。這類對(duì)象會(huì)保持靜止或者很輕微的移動(dòng)。對(duì)于環(huán)境模型十分好用,當(dāng)和剛體碰撞時(shí)而不會(huì)移動(dòng)。

Rigidbody Collider 剛體碰撞器

These GameObjects contain both a Rigidbody and a Collider. They are completely affected by the physics engine through scripted forces and collisions. They might collide with a GameObject that only contains a Collider. These will likely be your primary type of Collider in games that use physics.

指的是同時(shí)附加了剛體和碰撞器的游戲?qū)ο。通過(guò)腳本的力量和碰撞完全受物理引擎的影響?梢院椭话鲎财鞯挠螒?qū)ο笈鲎。將?huì)成為你游戲中使用物理效果的基本類型碰撞器。

Kinematic Rigidbody Collider 運(yùn)動(dòng)學(xué)剛體碰撞器

This GameObject contains a Collider and a Rigidbody which is marked IsKinematic. To move this GameObject, you modify its Transform Component, rather than applying forces. They're similar to Static Colliders but will work better when you want to move the Collider around frequently. There are some other specialized scenarios for using this GameObject.

指的是同時(shí)包含碰撞器和剛體,并且激活I(lǐng)sKinematic的一類游戲?qū)ο,要移?dòng)這類游戲?qū)ο,要修改它的Transform組件,而不是用力。它們很像靜態(tài)碰撞器不過(guò)對(duì)于想要不停地到處移動(dòng)的碰撞器很好用。這類游戲?qū)ο筮有許多其他的獨(dú)特使用情景。

This object can be used for circumstances in which you would normally want a Static Collider to send a trigger event. Since a Trigger must have a Rigidbody attached, you should add a Rigidbody, then enable IsKinematic. This will prevent your Object from moving from physics influence, and allow you to receive trigger events when you want to.

這類對(duì)象可以用于你通常希望用靜態(tài)碰撞器發(fā)出觸發(fā)事件的情形下。因?yàn)橛|發(fā)器必須要有剛體,你應(yīng)該添加剛體然后啟用IsKinematic。這會(huì)阻止你的對(duì)象因物理作用而移動(dòng)并且允許接收你希望得到的觸發(fā)事件。

Kinematic Rigidbodies can easily be turned on and off. This is great for creating ragdolls, when you normally want a character to follow an animation, then turn into a ragdoll when a collision occurs, prompted by an explosion or anything else you choose. When this happens, simply turn all your Kinematic Rigidbodies into normal Rigidbodies through scripting.

運(yùn)動(dòng)學(xué)剛體啟用與否很容易控制。這對(duì)創(chuàng)建人偶十分適用,通常,當(dāng)你希望一個(gè)角色依照動(dòng)畫(huà)活動(dòng),然后由于爆炸或者其他你選擇的情況而引起的碰撞導(dǎo)致其變?yōu)槿伺。這種情況下,很簡(jiǎn)單,只需要通過(guò)腳本將運(yùn)動(dòng)學(xué)剛體改為普通剛體。

If you have Rigidbodies come to rest so they are not moving for some time, they will "fall asleep". That is, they will not be calculated during the physics update since they are not going anywhere. If you move a Kinematic Rigidbody out from underneath normal Rigidbodies that are at rest on top of it, the sleeping Rigidbodies will "wake up" and be correctly calculated again in the physics update. So if you have a lot of Static Colliders that you want to move around and have different object fall on them correctly, use Kinematic Rigidbody Colliders.

如果有剛體有時(shí)候變得靜止不動(dòng)了,那么它們就是進(jìn)入休眠了。意味著它們將不受物理變化影響,也就不會(huì)移動(dòng)。如果你把一個(gè)運(yùn)動(dòng)學(xué)剛體從一個(gè)休眠的普通剛體下邊移走,那休眠的剛體就會(huì)被喚醒并重新被物理變化時(shí)時(shí)影響。所以如果你有許多希望四處移動(dòng)并有不同的對(duì)象要恰好砸到它們的靜態(tài)碰撞器,那就用運(yùn)動(dòng)學(xué)剛體碰撞器吧。

Collision action matrix 碰撞行為矩陣

Depending on the configurations of the two colliding Objects, a number of different actions can occur. The chart below outlines what you can expect from two colliding Objects, based on the components that are attached to them. Some of the combinations only cause one of the two Objects to be affected by the collision, so keep the standard rule in mind - physics will not be applied to objects that do not have Rigidbodies attached.

基于兩個(gè)碰撞對(duì)象的配置,可以產(chǎn)生很多不同的效果。下表概括了基于附加不同組件的兩個(gè)碰撞對(duì)象所產(chǎn)生的效果。其中有些組合只能導(dǎo)致碰撞的兩個(gè)對(duì)象中的一個(gè)受到影響,.所以考慮到保持標(biāo)準(zhǔn)的規(guī)則-物理效果將不會(huì)對(duì)沒(méi)有附加剛體的對(duì)象生效。

Collision detection occurs and messages are sent upon collision
碰撞后有碰撞檢測(cè)并有碰撞信息發(fā)出
 Static Collider
靜態(tài)碰撞器
Rigidbody Collider
剛體碰撞器
Kinematic
Rigidbody Collider
運(yùn)動(dòng)學(xué)剛體碰撞器
Static
Trigger Collider
靜態(tài)觸發(fā)碰撞器
Rigidbody
Trigger Collider
剛體觸發(fā)碰撞器
Kinematic Rigidbody
Trigger Collider
運(yùn)動(dòng)學(xué)剛體觸發(fā)碰撞器
Static Collider 靜態(tài)碰撞器 Y    
Rigidbody Collider 剛體碰撞器YYY   
Kinematic Rigidbody Collider
運(yùn)動(dòng)學(xué)剛體碰撞器
 Y    
Static Trigger Collider
靜態(tài)觸發(fā)碰撞器
      
Rigidbody Trigger Collider
剛體觸發(fā)碰撞器
      
Kinematic Rigidbody Trigger Collider
運(yùn)動(dòng)學(xué)剛體觸發(fā)碰撞器
      
Trigger messages are sent upon collision
碰撞后有觸發(fā)信息
 Static Collider
靜態(tài)碰撞器
Rigidbody Collider
剛體碰撞器
Kinematic
Rigidbody Collider
運(yùn)動(dòng)學(xué)剛體碰撞器
Static
Trigger Collider
靜態(tài)觸發(fā)碰撞器
Rigidbody
Trigger Collider
剛體觸發(fā)碰撞器
Kinematic Rigidbody
Trigger Collider
運(yùn)動(dòng)學(xué)剛體觸發(fā)碰撞器
Static Collider 靜態(tài)碰撞器    YY
Rigidbody Collider 剛體碰撞器   YYY
Kinematic Rigidbody Collider
運(yùn)動(dòng)學(xué)剛體碰撞器
   YYY
Static Trigger Collider 靜態(tài)觸發(fā)碰撞器 YY YY
Rigidbody Trigger Collider
剛體觸發(fā)碰撞器
YYYYYY
Kinematic Rigidbody Trigger Collider
運(yùn)動(dòng)學(xué)剛體觸發(fā)碰撞器
YYYYYY
Layer-Based Collision Detection 基于層的碰撞檢測(cè)

In Unity 3.x we introduce something called Layer-Based Collision Detection, and is that you can now selectively tell Unity GameObjects to collide with specific layers they are attached to. For more info, you can click here

在Unity3以后版本,我們介紹了一種稱為"基于層的碰撞檢測(cè)"(Layer-Based Collision Detection)的東西,可以讓你有選擇地控制Unity對(duì)象和他們附加的特定層碰撞。點(diǎn)擊此處獲取更多信息。

贊0 踩0

未知用戶

2005-2024 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號(hào)-1
2005-2024 ZhuFeng Community All Rights Reserved

VIP

朱峰社區(qū)微信公眾號(hào)

回頂部

1.復(fù)制文本發(fā)給您的QQ好友或群、微信等;好友點(diǎn)擊鏈接以后,轉(zhuǎn)發(fā)就成功了。 2.如朋友點(diǎn)擊您的鏈接,您需要需刷新一下才行;同一個(gè)好友僅能點(diǎn)擊一次。
購(gòu)買VIP,觀看所有收費(fèi)教程。