当前位置:网站首页>unity2d的Rigidbody2D的MovePosition函数移动时人物或屏幕抖动问题解决
unity2d的Rigidbody2D的MovePosition函数移动时人物或屏幕抖动问题解决
2022-07-07 16:51:00 【Cingke是真的】
这是一个2d刚体移动函数
public void controlHero()
{
if ((ETCInput.GetAxis("Vertical") != 0) || (ETCInput.GetAxis("Horizontal") != 0)){
rigidbody2D.MovePosition(rigidbody2D.position+Time.fixedDeltaTime*new Vector2(ETCInput.GetAxis("Horizontal"),ETCInput.GetAxis("Vertical")) * speed );
}
//众所周知,人物移动时乘以Time.fixedDeltaTime,相当于逻辑在FixedUpade中调用,每间隔0.02s移动一次;
}
我一开始是放在FixedUpdate()中调用,结果不出意外地人物抖动了,改了很多次,以为是移动是不够平滑,后来才知道,要考虑相机的跟随渲染,一般的相机跟随都放在了LateUpdate里,而我用的cinemachine也是在LateUpdate里,果断改成了在LateUpdate里调用移动函数,不抖动了。
private void LateUpdate()
{
controlHero();
}
}
好吧放在Update也可以
边栏推荐
- Antisamy: a solution against XSS attack tutorial
- Nunjuks template engine
- Skills of embedded C language program debugging and macro use
- Will low code help enterprises' digital transformation make programmers unemployed?
- Performance test process and plan
- The highest level of anonymity in C language
- 低代码助力企业数字化转型会让程序员失业?
- socket编程之常用api介绍与socket、select、poll、epoll高并发服务器模型代码实现
- Thread pool and singleton mode and file operation
- CVPR 2022丨学习用于小样本语义分割的非目标知识
猜你喜欢
socket編程之常用api介紹與socket、select、poll、epoll高並發服務器模型代碼實現
Tips for short-term operation of spot silver that cannot be ignored
Backup Alibaba cloud instance OSS browser
Industry case | digital operation base helps the transformation of life insurance industry
线程池和单例模式以及文件操作
Some key points in the analysis of spot Silver
DataSimba推出微信小程序,DataNuza接受全场景考验? | StartDT Hackathon
Do you really understand sticky bag and half bag? 3 minutes to understand it
Antisamy: a solution against XSS attack tutorial
海量数据去重的hash,bitmap与布隆过滤器Bloom Filter
随机推荐
Unlike the relatively short-lived industrial chain of consumer Internet, the industrial chain of industrial Internet is quite long
Tips of the week 136: unordered containers
Ten thousand words nanny level long article -- offline installation guide for datahub of LinkedIn metadata management platform
[paper sharing] where's crypto?
Thread pool and singleton mode and file operation
Charles+Postern的APP抓包
Datasimba launched wechat applet, and datanuza accepted the test of the whole scene| StartDT Hackathon
高考填志愿规则
PHP面试题 foreach($arr as &$value)与foreach($arr as $value)的用法
Do you really understand sticky bag and half bag? 3 minutes to understand it
gsap动画库
socket編程之常用api介紹與socket、select、poll、epoll高並發服務器模型代碼實現
Disk storage chain B-tree and b+ tree
Tips of this week 141: pay attention to implicit conversion to bool
企业展厅设计中常用的三种多媒体技术形式
线程池中的线程工厂
SQLite SQL exception near "with": syntax error
[trusted computing] Lesson 12: TPM authorization and conversation
[paddleseg source code reading] add boundary IOU calculation in paddleseg validation (1) -- val.py file details tips
Redis集群与扩展