using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateAndScale : MonoBehaviour
{
public Transform target; // Target to scale
public Vector3 minScale; // Minimum scale value
public Vector3 maxScale; // Maximum scale value
public Vector3 maxRotate;
public Vector3 minRotate;
public float speed;
private float t = 0.0f;
void Update()
{
//if (Input.GetKey(KeyCode.C))
//{
t += speed * Time.deltaTime;
target.localScale = Vector3.Lerp(target.localScale, maxScale, t);
target.localRotation = Quaternion.Lerp(target.localRotation,
Quaternion.Euler(maxRotate.x, maxRotate.y, maxRotate.z), t);
// }
}
}
这将缩放并旋转对象至最大一次。但我希望它达到最大,然后回到最小,然后回到最大和最小不间断。
然后,我想使用一个键,例如C,当在C上按下一次时,它将最大化,而在C上再次按下,它将回到最小。
但是首先我不确定如何使用乒乓不停,然后如何使用钥匙?