ict.xunfei/Assets/Temp/Cal.cs

33 lines
641 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class Cal : MonoBehaviour
{
public Vector3 tar;
public float dur;
public bool cal;
public float timer;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
cal = true;
timer = 0;
transform.DOMove(tar, dur).OnComplete(() => { cal = false; });
}
if (cal)
{
timer += Time.deltaTime;
}
}
}