public class Player:MonoBehaviour
{
private void Start()
{
}
private void Update()
{
Movement();
}
private void Movement()
{
LimitPosition();
}
private void LimitPosition()
{
Vector3 screenPosition = Camera.main.WorldToScreenPoint(this.transform.position);
screenPoint.x = Mathf.Clamp(screenPoint.x,0,Screen.width);
screenPoint.y = Mathf.Clamp(screenPoint.y,0,Screen.height);
}
}
U3D中控制物体不离开屏幕
最新推荐文章于 2023-10-24 15:40:02 发布