【发布时间】:2020-09-23 11:02:41
【问题描述】:
如果一个对象与另一个游戏对象发生碰撞,我想增加它的大小。我使用这个脚本:
void OnTriggerEnter2D(Collider2D other) //Unity function called when a collision is detected, and the object collided is put into the variable 'col' to be used later
{
if(other.gameObject.tag == "enemy") //if the object you collided with is the enemy
{
transform.localScale += new Vector3 (1,1,1); //increase the size of the ball
Destroy(other.gameObject); //Destroy the enemy
}
}
}
问题是:我想增加的对象变大到快。我试过放双打,但当然不行。有人有解决方法吗?
最好的问候 大春哥
【问题讨论】:
-
YSK
1.0被 C# 检测为double,Vector3不支持。1.0f被检测为float,Vector3支持。double是 64 位的,对于游戏中的所有物理和图形,每帧计算多次非常昂贵。显卡可以处理 32 位float的变量,比 64 位double快很多。
标签: c# unity3d game-engine