下面是我的碰撞脚本的一部分,一切正常。
我试图弄清楚如何让“播放器”进行平滑旋转并缩小播放器对象的比例。我该怎么办?我是否应该创建一个检查变量并检查更新方法以进行平滑旋转,但我不知道平滑缩放缩小。任何有关如何解决此问题的帮助将不胜感激。
if(blackholeActive == true){
player.transform.Rotate(new Vector3(0, 0, Time.deltaTime * -150));
player.transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(0.025f, 0.025f, 0.025f), 0.01f * Time.deltaTime);
}
// Black Hole Collision
if (col.gameObject.tag == "BlackHole")
{
Debug.Log("Black Hole");
int valC = coinCount;
//coinCount = 0;
int valS = starCount; // for stars lost text
//starCount = 0;
//Stop player from moving and falling and make them disappear into blackhole
player.transform.GetComponentInChildren<Rigidbody2D>().bodyType = RigidbodyType2D.Static;
player.GetComponentInChildren<Rigidbody2D>().velocity = Vector2.zero;
player.GetComponentInChildren<Rigidbody2D>().gravityScale = 0;
/// TODO: Stop Blackhole movement
/// Make player spin and shrink
blackholeActive = true;
coinsLost.text = "Coins Lost: " + valC;
starsLost.text = "Stars Lost: " + valS;
gameOverCanvas.gameObject.SetActive(true);
}