当我按下左箭头时我想缩小精灵并且当我按右箭头时我想放大精灵。我制作了这个代码,它的工作原理非常快速。如果我按下按钮1秒钟,它可以扩展到100万次。我究竟做错了什么? scalingSpeed
就像0.0001,但它仍然很快疯狂。通过按下按钮来缩放精灵
if(Input.GetKey (KeyCode.LeftArrow)) {
this.transform.localScale -= new Vector3 (this.transform.localScale.x - scalingSpeed, this.transform.localScale.y - scalingSpeed, 0);
} else if (Input.GetKey (KeyCode.RightArrow)) {
this.transform.localScale += new Vector3 (this.transform.localScale.x - scalingSpeed, this.transform.localScale.y - scalingSpeed, 0);
}
您是否能够找到解决问题的方法?如果给出的答案不能提供您所需的答案,请在此处添加评论或编辑您的问题以进行澄清。谢谢! – Serlite