包含11節(jié)視頻教程
從零基礎(chǔ)學(xué)習(xí)unity3d游戲引擎,簡(jiǎn)單易學(xué)的視頻教程,讓你快速掌握unity3d,并喜歡上游戲開發(fā)的樂趣。
![]()
|
![]()
Properties 屬性
Details 細(xì)節(jié)Fixed Timestep 固定時(shí)間步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. 固定時(shí)步對(duì)穩(wěn)定的物理模擬非常重要。不同計(jì)算機(jī)的硬件配置在運(yùn)行unity的游戲時(shí)有不同的性能表現(xiàn)。因此物理模擬必須獨(dú)立于幀速率進(jìn)行計(jì)算。碰撞檢測(cè)和剛體運(yùn)動(dòng)等物理計(jì)算在離散的固定時(shí)步中執(zhí)行,與幀速率無(wú)關(guān)。這使得物理模擬在不同的計(jì)算機(jī)上或幀速率發(fā)生變化時(shí)是一致的。例如,游戲屏幕內(nèi)容的變化和用戶在后臺(tái)執(zhí)行程序都會(huì)導(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. 以下是固定時(shí)步如何計(jì)算。在每一幀圖像繪制到屏幕之前,Unity將固定時(shí)間加上固定時(shí)步,然后執(zhí)行物理計(jì)算,直到它到達(dá)當(dāng)前時(shí)間。該過程與固定時(shí)步屬性直接相關(guān)。固定時(shí)步值越小,物理計(jì)算就越頻繁。將1除以固定時(shí)步可以得到每秒計(jì)算固定幀的數(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. 簡(jiǎn)而言之,一個(gè)較小的固定更新值可以得到更準(zhǔn)確的物理模擬,但CPU的負(fù)擔(dān)會(huì)加重。 Maximum Allowed Timestep 最大時(shí)間步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. 固定時(shí)步可以確保穩(wěn)定的物理模擬。然而,如果游戲的物理計(jì)算過多導(dǎo)致運(yùn)行緩慢或者幀速率間或降低,會(huì)造成負(fù)面影響。幀的處理時(shí)間越長(zhǎng),要執(zhí)行的固定時(shí)步更新次數(shù)就越多,這會(huì)導(dǎo)致性能下降。為了防止這種情況,Unity iOS通過引入最大時(shí)步來(lái)確保物理計(jì)算不會(huì)超過指定的閾值。 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. 如果幀的處理時(shí)間超過了最大時(shí)步,物理引擎會(huì)"假裝"該幀只消耗了最大時(shí)步的時(shí)間。換句話說,如果幀速率下降到低于某個(gè)閾值,剛體將會(huì)放慢一點(diǎn)讓CPU趕上。 Maximum Allowed Timestep affects both physics calculation and FixedUpdate() events. 最大時(shí)步對(duì)物理計(jì)算和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í)步的單位是秒。因此設(shè)置為0.1時(shí),如果幀速率低于1 /0.1=每秒10幀,物理計(jì)算和FixedUpdate()事件將會(huì)放慢。 Typical scenario 典型場(chǎng)景
Hints 提示
贊0 踩0 |
未知用戶
2005-2025 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號(hào)-1
2005-2025 ZhuFeng Community All Rights Reserved
VIP