包含5節(jié)視頻教程
本系列包含Unity3D介紹、Unity3D導(dǎo)出人物、Unity3D導(dǎo)出場景、Unity3D導(dǎo)出動作、游戲測試最終完成一個簡單的游戲。是一套非常完整的Unity3D游戲制作教程。
|
Properties 屬性
Details 細(xì)節(jié)Fixed Timestep 固定時間步Fixed time stepping is very important for stable physics simulation. Not all computers are made equal, and different hardware configurations will run Unity games with varying performance. Therefore, physics must be calculated independently of the game's frame rate. Physics calculations like collision detection and Rigidbody movement are performed in discrete fixed time steps that are not dependent on frame rate. This makes the simulation more consistent across different computers or when changes in the frame rate occur. For example, the frame rate can drop due to an appearance of many game onscreen, or because the user launched another application in the background. 固定時步對穩(wěn)定的物理模擬非常重要。不同計算機的硬件配置在運行unity的游戲時有不同的性能表現(xiàn)。因此物理模擬必須獨立于幀速率進(jìn)行計算。碰撞檢測和剛體運動等物理計算在離散的固定時步中執(zhí)行,與幀速率無關(guān)。這使得物理模擬在不同的計算機上或幀速率發(fā)生變化時是一致的。例如,游戲屏幕內(nèi)容的變化和用戶在后臺執(zhí)行程序都會導(dǎo)致幀速率下降。 Here's how the fixed time step is calculated. Before every frame is drawn onscreen, Unity advances the fixed time by fixed delta time and performs physics calculations until it reaches the current time. This directly correlates to the Fixed Timestep property. The smaller the value of Fixed Timestep, the more frequently physics will be calculated. The number of Fixed frames per second can be calculated by dividing 1 by Fixed Timestep. Therefore, 1 / 0.02 = 50 fixed frames per second and 1 / 0.05 = 20 fixed frames per second. 以下是固定時步如何計算。在每一幀圖像繪制到屏幕之前,Unity將固定時間加上固定時步,然后執(zhí)行物理計算,直到它到達(dá)當(dāng)前時間。該過程與固定時步屬性直接相關(guān)。固定時步值越小,物理計算就越頻繁。將1除以固定時步可以得到每秒計算固定幀的數(shù)量。所以,1 /0.02=50固定幀每秒,1 /0.05=20固定幀每秒。 Simply put, a smaller fixed update value leads to more accurate physics simulation but is heavier on the CPU. 簡而言之,一個較小的固定更新值可以得到更準(zhǔn)確的物理模擬,但CPU的負(fù)擔(dān)會加重。 Maximum Allowed Timestep 最大時間步Fixed time stepping ensures stable physics simulation. However it can cause negative impact on performance if game is heavy on physics and is already running slow or occasionally dips to low frame rate. Longer the frame takes to process - more fixed update steps will have to be executed for the next frame. This results in performance degradation. To prevent such scenario Unity iOS introduced Maximum Allowed Timestep which ensures that physics calculations will not run longer than specified threshold. 固定時步可以確保穩(wěn)定的物理模擬。然而,如果游戲的物理計算過多導(dǎo)致運行緩慢或者幀速率間或降低,會造成負(fù)面影響。幀的處理時間越長,要執(zhí)行的固定時步更新次數(shù)就越多,這會導(dǎo)致性能下降。為了防止這種情況,Unity iOS通過引入最大時步來確保物理計算不會超過指定的閾值。 If frame takes longer to process than time specified in Maximum Allowed Timestep, then physics will "pretend" that frame took only Maximum Allowed Timestep seconds. In other words if frame rate drops below some threshold, then rigid bodies will slow down a bit allowing CPU to catch up. 如果幀的處理時間超過了最大時步,物理引擎會"假裝"該幀只消耗了最大時步的時間。換句話說,如果幀速率下降到低于某個閾值,剛體將會放慢一點讓CPU趕上。 Maximum Allowed Timestep affects both physics calculation and FixedUpdate() events. 最大時步對物理計算和FixedUpdate()事件都有影響。 Maximum Allowed Timestep is specified in seconds as Fixed Timestep. Therefore setting 0.1 will make physics and FixedUpdate() events to slow down, if frame rate dips below 1 / 0.1 = 10 frames per second. 最大時步的單位是秒。因此設(shè)置為0.1時,如果幀速率低于1 /0.1=每秒10幀,物理計算和FixedUpdate()事件將會放慢。 Typical scenario 典型場景
Hints 提示
贊0 踩0 |
未知用戶
2005-2024 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號-1
2005-2024 ZhuFeng Community All Rights Reserved
VIP