2015年11月26日 星期四

Unity Wheel Collider

Unity 製作賽車遊戲常用的 component 變得方便許多了,以前都是要經過計算及動畫來表現。

Unity wheel collider component 圖示:


功能說明:

English :

MassThe Mass of the wheel.
RadiusRadius of the wheel.
Wheel Damping RateThis is a value of damping applied to a wheel.
Suspension DistanceMaximum extension distance of wheel suspension, measured in local space. Suspension always extends downwards through the local Y-axis.
Force App Point DistanceThis parameter defines the point where the wheel forces will applied. This is expected to be in metres from the base of the wheel at rest position along the suspension travel direction. When forceAppPointDistance = 0 the forces will be applied at the wheel base at rest. A better vehicle would have forces applied slightly below the vehicle centre of mass.
CenterCenter of the wheel in object local space.
Suspension SpringThe suspension attempts to reach a Target Position by adding spring and damping forces.
        SpringSpring force attempts to reach the Target Position. A larger value makes the suspension reach the Target Position faster.
        DamperDampens the suspension velocity. A larger value makes the Suspension Spring move slower.
        Target PositionThe suspension’s rest distance along Suspension Distance. 0 maps to fully extended suspension, and 1 maps to fully compressed suspension. Default value is zero, which matches the behavior of a regular car’s suspension.
Forward/Sideways FrictionProperties of tire friction when the wheel is rolling forward and sideways. See the Wheel Friction Curves section below.
中文:

質量車輪的質量。
半徑半徑的車輪。
滾輪阻尼率這是阻尼施加到車輪的值。
懸掛距離車輪懸架的最大延伸距離,在本地空間測量。懸浮液總是通過本地Y軸向下延伸。
力應用點距離此參數定義了輪子上的力會作用點。這是預期要在米從輪的基部沿懸架行程方向靜止位置。當力任命距離=0的力將在休息時的軸距被應用。一個更好的車輛將有力量施加略低於大眾的車輛中心。
中央車輪在對象的局部空間的中心。
懸架彈簧將懸浮試圖通過增加彈簧和阻尼力將達到一個目標位置。
彈簧彈簧力試圖到達目標位置。較大的值使懸架到達目標位置更快。
避震減震器懸浮速度。較大的值,使懸架彈簧移動速度較慢。
目標位置該懸掛其餘的距離沿懸架距離。 0映射到完全伸展懸浮液中,和1映射到完全壓縮懸浮液。默認值是零,其匹配常規汽車的懸架的行為。
前進
側身摩擦
輪胎摩擦的性質時,車輪滾滾向前和側面。請參閱下面的車輪摩擦曲線部分。


The Wheel Collider Component. Car model courtesy of ATI Technologies Inc.
該輪對撞機的組成部分。

Details :

The wheel’s collision detection is performed by casting a ray from Center downwards through the local Y-axis. The wheel has a Radius and can extend downwards according to the Suspension Distance. The vehicle is controlled from scripting using different properties:motorTorquebrakeTorque and steerAngle. See the Wheel Collider scripting reference for more information.
The Wheel Collider computes friction separately from the rest of physics engine, using a slip-based friction model. This allows for more realistic behaviour but also causes Wheel Colliders to ignore standard Physic Material settings.
由向下通過局部Y軸鑄造從中心射線進行車輪的碰撞檢測。該輪具有半徑,並且可以根據懸架距離向下延伸。制動力矩和轉向角:車輛從腳本使用不同的屬性控制。更多信息請參見該輪胎碰撞器腳本參考
該輪對撞機分開計算摩擦力的物理引擎的其餘部分,採用了防滑基於摩擦模型。這樣就可以更真實的行為,而且會導致車輪撞機忽略標準物理學材質設置

Wheel collider setup:

    You do not turn or roll WheelCollider objects to control the car - the objects that have the WheelCollider attached should always be fixed relative to the car itself. However, you might want to turn and roll the graphical wheel representations. The best way to do this is to setup separate objects for Wheel Colliders and visible wheels:
    你不轉或滾動WheelCollider對象來控制汽車 - 具有連接的WheelCollider應始終相對於汽車本身固定的對象。但是,您可能要轉向和滾動圖形車輪表示。


Wheel Colliders are separate from visible Wheel Models
Wheel Colliders are separate from visible Wheel Models
輪對撞機是分開可見車輪模型

※ But in my experience:

Each engineer art create 3D models differ in the center, it is proposed to create an empty object, the establishment of sub-item under item was added tire air collision in the component (wheelcollider component), so as to effectively control.

※ 但是以我的經驗來看的話:

每一個美術工程師在建立3D模型的中心有所不同,所以建議先建立一個空物件,在空物件底下建立子物件再加入輪胎碰撞器的組件(wheel collider component),這樣才能有效的控制。


Note that the gizmo graphic for the WheelCollider’s position is not updated in playmode:
Position of WheelCollider Gizmo in runtime using a suspension distance of 0.15

Position of WheelCollider Gizmo in runtime using a suspension distance of 0.15
WheelCollider小控件使用0.15的懸浮距離運行時的位置

Collision geometry

Because cars can achieve large velocities, getting race track collision geometry right is very important. Specifically, the collision mesh should not have small bumps or dents that make up the visible models (e.g. fence poles). Usually a collision mesh for the race track is made separately from the visible mesh, making the collision mesh as smooth as possible. It also should not have thin objects - if you have a thin track border, make it wider in a collision mesh (or completely remove the other side if the car can never go there).

碰撞幾何
因為汽車可以實現較大的速度,讓賽道碰撞幾何權是非常重要的。具體地,碰撞網格不應有小的凸起或凹陷構成可見模型(例如柵欄極)。一般碰撞網格為賽道分開可見網格製成,使得碰撞網眼盡可能平滑。它也應該不會有薄的對象 - 如果你有一個薄的軌道邊界,使其在碰撞網格較寬(或完全刪除對方如果汽車不能去那裡)。
Visible geometry (left) is much more complex than collision geometry (right)
Visible geometry (left) is much more complex than collision geometry (right)
可見幾何結構(左)遠高於碰撞幾何更為複雜(右)

Wheel Friction Curves

Tire friction can be described by the Wheel Friction Curve shown below. There are separate curves for the wheel’s forward (rolling) direction and sideways direction. In both directions it is first determined how much the tire is slipping (based on the speed difference between the tire’s rubber and the road). Then this slip value is used to find out tire force exerted on the contact point.
The curve takes a measure of tire slip as an input and gives a force as output. The curve is approximated by a two-piece spline. The first section goes from (0 , 0) to (ExtremumSlip , ExtremumValue), at which point the curve’s tangent is zero. The second section goes from(ExtremumSlip , ExtremumValue) to (AsymptoteSlip , AsymptoteValue), where curve’s tangent is again zero:
車輪摩擦曲線
輪胎摩擦可以由下面所示的車輪摩擦曲線進行說明。有用於輪的正向(軋製)方向和橫方向單獨的曲線。在兩個方向上,首先確定多少輪胎打滑(基於輪胎的橡膠和道路之間的速度差)。然後結束該打滑值被用於找出施加在接觸點輪胎力。
曲線取輪胎打滑的度量作為輸入,並給出一個力作為輸出。該曲線是通過兩件式花鍵近似。第一部分變為從(0,0)至(極值滑移,極值值),在該點處曲線的切線是零。第二部分從去(極值滑,極值)至(漸近線滑動,漸近線值),其中曲線的切線再次為零:
Typical shape of a wheel friction curve
Typical shape of a wheel friction curve
The property of real tires is that for low slip they can exert high forces, since the rubber compensates for the slip by stretching. Later when the slip gets really high, the forces are reduced as the tire starts to slide or spin. Thus, tire friction curves have a shape like in the image above.
真正的輪胎的特性是低轉差,他們可以發揮大的力,因為橡膠補償滑通過拉伸。後來,當滑動變得非常高,力減小輪胎開始滑動或旋轉。因此,輪胎摩擦曲線有像上述圖像中的一個的形狀。
Property:Function:
Extremum Slip/ValueCurve’s extremum point.
Asymptote Slip/ValueCurve’s asymptote point.
StiffnessMultiplier for the Extremum Value and Asymptote Value (default is 1). Changes the stiffness of the friction. Setting this to zero will completely disable all friction from the wheel. Usually you modify stiffness at runtime to simulate various ground materials from scripting.

:方法:
極值滑/值曲線的極值點。
漸近線滑動/值曲線的漸近線點。
剛性乘數的極值和漸近值(默認為1)。改變了摩擦的剛度。這個設置為零將完全禁用來自車輪的所有摩擦。通常你修改剛度在運行時模擬從腳本各種地面材料.

Hints


  • You might want to decrease physics timestep length in Time Manager to get more stable car physics, especially if it’s a racing car that can achieve high velocities.


  • To keep a car from flipping over too easily you can lower its Rigidbody center of mass a bit from script, and apply “down pressure” force that depends on car velocity.

提示


  • 您可能要減少物理時間步長的時間管理以獲得更穩定的汽車物理,尤其是如果它是一輛賽車,可以實現較高的速度。
  • 保持車子的翻轉過也很容易就可以降低其剛體質心一點從劇本,並應用依賴於汽車的速度“下壓”的力量。


資料來源: http://docs.unity3d.com/Manual/class-WheelCollider.html

Car Controller Project (JS)  

沒有留言:

張貼留言