Files
2026-05-26 16:15:54 +08:00

28 lines
612 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Calculate : MonoBehaviour
{
public float Height = 1;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
// 按下tab键计算掉落用时
if (Input.GetKey(KeyCode.Tab))
{
float g = Mathf.Abs(Physics2D.gravity.y);
float t2 = 2 * Height / g;
float t = Mathf.Sqrt(t2);
Debug.Log("从高度 " + Height + " 米掉落,耗时 " + t + "s");
}
}
}