📜  如何通过变换移动玩家.位置 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:49.454000             🧑  作者: Mango

代码示例2
public class bbo2 : MonoBehaviour
{

    private const float _minimumHeldDuration = 0.25f;
    private float _holdPressedTime = 0.5f;
    


    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetButton("m"))
        {
            if (Time.timeSinceLevelLoad - _holdPressedTime > _minimumHeldDuration)
            {
                transform.position += new Vector3(10f, 0, 0) * Time.deltaTime;
            }
        }
    }
}