初始化提交
This commit is contained in:
23
Assets/Scripts/PlayerMove.cs
Normal file
23
Assets/Scripts/PlayerMove.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
// 控制玩家移动
|
||||
public class PlayerMove : MonoBehaviour
|
||||
{
|
||||
private Vector3 _targetPosition;
|
||||
private const float SmoothSpeed = 10f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_targetPosition = transform.position;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
transform.position = Vector3.Lerp(transform.position, _targetPosition, SmoothSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
public void SetPosition(float x, float y)
|
||||
{
|
||||
_targetPosition = new Vector3(x / 100, y / 100, 0f);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user