unity让碰撞只发生一次

碰撞发生在帧的开始,所以你可以检测到冲突,并在LateUpdate复位:

private bool hasCollided = false; 
void OnCollisionEnter(Collision col) 
{ 
    if(this.hasCollided == true){ return; } 
    this.hasCollided = true; 
} 
void LateUpdate() 
{ 
    this.hasCollided = false; 
}

猜你喜欢

转载自www.cnblogs.com/sanyejun/p/11439002.html