unity 2D 移动系统选择使用Rigidbody还是Transform
https://www.reddit.com/r/Unity2D/comments/6dhbcb/should_i_use_transformposition_or/
非强物理游戏,感觉还是直接使用Transform可控性好一些。。。
I started off with a sort of hybrid system, where I used velocity for jumping / gravity, and horizontal movement using transform translation, but I'm currently in the process of switching to a non rigidbody system.
Here's what I would say advantages to a rigidbody system are:
-
Physically realistic movement, adding forces gives you nice acceleration behavior. [真实的物理移动、“力”、加速度]
-
Don't need any additional code to get collisions or gravity working [碰撞和重力逻辑的自动处理]
-
Can push around other rigidbody objects with no additional work.[推动其他物体]
Disadvantages of rigidbody:
-
Have to jump through hoops if you want "unrealistic" movement.[如果像要“非物理”的移动,很麻烦]
-
Relative movement (such as on a moving platform) can be a nightmare (at least it was for me, and is the reason I'm switching in my game)【移动平台的相对移动不好处理】
-
More expensive computationally / in memory.【性能】
Advantages of custom collider controller:
-
Less computationally expensive.【性能】
-
Can fine tune object's behavior to move exactly how you want without worrying if you can do it with physics forces.【自定义控制】
Disadvantages of custom controller:
-
Have to program all the interactions yourself.【编程压力】
-
Maths.【数学计算要求。还是编程压力】
I would say the rigidbody is much easier to get going from scratch, but more complex interactions will be difficult later on. While a custom controller is a bit of work to get started, but easy to fiddle with afterwords.
If you want to go with a custom controller I highly recommend Sebastian Lague's 2D platform tutorial, which can be found here.
Also on a side note, you can add a physics material with a friction value of your choosing to the box collider on your player, which should have them slow down once you let go.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
2016-03-28 C#使用正则表达式检测数字 char 和韩文