欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

MonoBehaviour.FixedUpdate 固定更新

发布时间:2023/12/13 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 MonoBehaviour.FixedUpdate 固定更新 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

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启用时被调用。实现组件功能时重载这个函数。

转载于:https://www.cnblogs.com/vincentDr/p/3681062.html

总结

以上是生活随笔为你收集整理的MonoBehaviour.FixedUpdate 固定更新的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。