function?FixedUpdate?() : void
Description描述
This function is called every fixed framerate frame, if the MonoBehaviour is enabled.
當MonoBehaviour啟用時,其?FixedUpdate?在每一幀被調用。
FixedUpdate should be used instead of Update when dealing with?Rigidbody?. For example when adding a force to a rigidbody, you have to apply the force every fixed frame inside FixedUpdate instead of every frame inside Update.
處理Rigidbody時,需要用FixedUpdate代替Update。例如:給剛體加一個作用力時,你必須應用作用力在FixedUpdate里的固定幀,而不是Update中的幀。(兩者幀長不同)
// Apply a upwards force to the rigid body every frame // 每幀應用一個向上的力到剛體上 function FixedUpdate () {rigidbody.AddForce ( Vector3.up ); }
In order to get the elapsed time since last call to FixedUpdate, use?Time.deltaTime?This function is only called if the?Behaviour?is enabled. Override this function in order to provide your component's functionality.
為了獲取自最后一次調用FixedUpdate所用的時間,可以用Time.deltaTime。這個函數只有在Behaviour啟用時被調用。實現組件功能時重載這個函數。