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.