Update()介绍


首先我们从官方文档的介绍了解:

MonoBehaviour.Update()

  • Description

Update is called every frame, if the MonoBehaviour is enabled. Update is the most commonly used function to implement anykind of game behaviour.

using UnityEngine;
using System.Collections; public class ExampleClass : MonoBehaviour {
void Update() {
transform.Translate(0, 0, Time.deltaTime * 1);
}
}

In order to get the elapsed time since last call to Update, 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()介绍


  • Description

This function is called every fixed framerate frame, if the MonoBehaviour is enabled. 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 everyframe inside Update.

using UnityEngine;
using System.Collections; public class ExampleClass : MonoBehaviour
{
public Rigidbody rb; void Start()
{
rb = GetComponent<Rigidbody>();
} void FixedUpdate()
{
rb.AddForce(10.0f * Vector3.up);
}
}

In order to get the elapsed time since last call to Update, 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的调用时间是固定的,与帧数无关,而update与当前平台的帧数有关,也就是说如果因为你的机器性能有所差异,表现出来的游戏帧数不同,那么update()的调用时间间隔也会不一样,而fixedupdate()的调用时间却是相同的,并且从上面的官方手册中我们可以了解到,如果要对物理刚体进行处理,应该调用的是fixupdate()

附上youtube二者的官方教程视频:

https://www.youtube.com/watch?v=ZukcUv3pyXQ

[Unity]Update()与FixedUpdate()的更多相关文章

  1. unity update与fixedUpdate

    update与渲染同步.fixedUpdate与物理同步. 在update中,speed要乘以Time.deltaTime.在fixedUpdate中,speed要乘以Time.fixedDeltaT ...

  2. Unity游戏暂停之Update与FixedUpdate区别

    游戏暂停 示例程序 下面这段代码演示游戏暂停 using UnityEngine; using System.Collections; public class GamePauseTest : Mon ...

  3. Unity的Update() 和 FixedUpdate()的区别

    Update() 和 FixedUpdate()在游戏中都会在更新的时候自动循环调用. 但是Update是在每次渲染新的一帧的时候才会调用,也就是说,这个函数的更新频率和设备的性能有关以及被渲染的物体 ...

  4. Unity之Update与FixedUpdate区别

    下面这段代码演示游戏暂停 using UnityEngine; using System.Collections; public class GamePauseTest : MonoBehaviour ...

  5. [Unity-7] Update和FixedUpdate

    1.Update和FixedUpdate这是Unity既用内提供的帧功能接口相关联. Update():这个函数里面的内容每一帧都会被运行一次.这个函数有一个特点,那就是运行的频率等于帧率.而这个帧率 ...

  6. Cocos2d中update与fixedUpdate的区别(一)

    原文链接 关于这个问题cocos2d中的fixedUpdate:(或者是Unity中的FixedUpdate)在不同论坛中出现略显频繁.它被回答过很多次了,不管如何,每次一些童鞋在得到答案后还是有一些 ...

  7. 分别在Update和FixedUpdate使用GetKeyDown

    测试目的 探究分别在Update和FixedUpdate使用GetKeyDown执行次数,会不同的 测试开始 在Update测试 我们先在Update测试,很正常是一帧重置一下状态,以防止点击一下执行 ...

  8. Unity3D中Update()与FixedUpdate()的区别

    Unity3D中Update()与FixedUpdate()的区别是什么呢?从字面上理解,它们都是在更新时会被调用,并且会循环的调用.但是Update会在每次渲染新的一帧时,被调用.而FixedUpd ...

  9. 【转】 Update和FixedUpdate的区别

    MonoBehaviour.Update 更新 当MonoBehaviour启用时,其Update在每一帧被调用. MonoBehaviour.FixedUpdate 固定更新 当MonoBehavi ...

  10. update与fixedupdate差别

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网--Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=307 今天有人问我问什么我在处 ...

随机推荐

  1. 7.MongoDB系列之聚合框架

    1. 管道阶段和可调参数 聚合框架基于管道的概念.他由多个阶段组成,每个阶段都会提供一组按钮或可调参数.每个阶段对其输入执行不同的数据处理任务,并生成文档已作为输出传递到下一阶段. 2. 阶段常见操作 ...

  2. [Oracle]复习笔记-SQL部分内容

    Oracle笔记--SQL部分 整体框架 语句的执行顺序:from →where →group by→having→select→order by select * from * where * gr ...

  3. 5.@pytest.mark.parametrize()数据驱动

    简介: pytest.mark.parametrize 是 pytest 的内置装饰器,它允许你在 function 或者 class 上定义多组参数和 fixture 来实现数据驱动. @pytes ...

  4. 二、python基本数据类型

    一. 字面量 代码中,被写在代码中的固定的值,称之为字面量 Python常用6种值(数据)类型 字符串(string) :又称文本,是由任意数量的字符如中文.英文.各类符号.数字等组成.所以叫做字符的 ...

  5. Ruoyi表单构建

    Ruoyi表单构建通过拖动组件就能自动生成前端代码,很方便,所以本文简单通过上层函数源码来梳理一下大致流程,如有需要再自行仔细一行行分析底层代码. 组件拖动 实现组件拖动功能主要依赖第三方库:VueD ...

  6. 云原生之旅 - 6)不能错过的一款 Kubernetes 应用编排管理神器 Kustomize

    前言 相信经过前一篇文章的学习,大家已经对Helm有所了解,本篇文章介绍另一款工具 Kustomize,为什么Helm如此流行,还会出现 Kustomize?而且 Kustomize 自 kubect ...

  7. iOS- 最全的真机测试教程

      想要上架的同学请看:<iOS-最全的App上架教程> 因为最近更新了Xcode 8 ,证书的创建都大同小异,只是在Xcode 8中的设置有一些变化,我就在下面补充,如有什么疑问,请联系 ...

  8. 833——B题题解

    题目链接 题目大意: 给一串字符串(只包含0~9),定义一个最优子串的定义:如果该子串同字符种类数大于最最多字符出现数,那么这个子串可以被称为最优子串. 解题思路: 大眼一看这个数据范围他用n^2的算 ...

  9. hwlog--limiter.go

    // Copyright(C) 2021. Huawei Technologies Co.,Ltd. All rights reserved.// Package limiter implement ...

  10. 【云原生 · Kubernetes】部署kube-apiserver集群

    个人名片: 因为云计算成为了监控工程师‍ 个人博客:念舒_C.ying CSDN主页️:念舒_C.ying 部署kube-apiserver集群 10.1 创建kube-apiserver 证书 10 ...