当前位置:网站首页>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也可以
边栏推荐
- What are the financial products in 2022? What are suitable for beginners?
- Charles+drony的APP抓包
- Using stored procedures, timers, triggers to solve data analysis problems
- Kubernetes DevOps CD工具对比选型
- Ten thousand words nanny level long article -- offline installation guide for datahub of LinkedIn metadata management platform
- Differences between rip and OSPF and configuration commands
- Do you really understand sticky bag and half bag? 3 minutes to understand it
- Kirk Borne的本周学习资源精选【点击标题直接下载】
- Summary of evaluation indicators and important knowledge points of regression problems
- Charles+Postern的APP抓包
猜你喜欢

Standard ACL and extended ACL

Calculation of torque target value (ftorque) in servo torque control mode

Redis

面试唯品会实习测试岗、抖音实习测试岗【真实投稿】
![学习open62541 --- [67] 添加自定义Enum并显示名字](/img/98/e5e25af90b3f98c2be11d7d21e5ea6.png)
学习open62541 --- [67] 添加自定义Enum并显示名字

卖空、加印、保库存,东方甄选居然一个月在抖音卖了266万单书

Antisamy: a solution against XSS attack tutorial

Discuss | what preparations should be made before ar application is launched?

低代码助力企业数字化转型会让程序员失业?

小程序中实现付款功能
随机推荐
Differences between rip and OSPF and configuration commands
nest. Database for getting started with JS
6.关于jwt
Datasimba launched wechat applet, and datanuza accepted the test of the whole scene| StartDT Hackathon
[principle and technology of network attack and Defense] Chapter 6: Trojan horse
五种网络IO模型
Learn to make dynamic line chart in 3 minutes!
Will domestic software testing be biased
小试牛刀之NunJucks模板引擎
What is the general yield of financial products in 2022?
Do you really understand sticky bag and half bag? 3 minutes to understand it
[principles and technologies of network attack and Defense] Chapter 3: network reconnaissance technology
现在网上期货开户安全吗?国内有多少家正规的期货公司?
【C语言】字符串函数
[demo] circular queue and conditional lock realize the communication between goroutines
线程池的拒绝策略
Discuss | frankly, why is it difficult to implement industrial AR applications?
Charles+drony的APP抓包
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的
小程序中实现付款功能