Unity 2d jumping script

后端 未结 3 1842
北恋
北恋 2021-01-02 01:37

Does anyone have a good jumping script for 2d games in unity? The code I have works but still is far from jumping, it looks like it is flying.

using UnityEng         


        
3条回答
  •  旧巷少年郎
    2021-01-02 02:18

    Usually for jumping people use Rigidbody2D.AddForce with Forcemode.Impulse. It may seem like your object is pushed once in Y axis and it will fall down automatically due to gravity.

    Example:

    rigidbody2D.AddForce(new Vector2(0, 10), ForceMode2D.Impulse);
    

提交回复
热议问题