OnCollisionEnter 不工作 Unity3d 5
OnCollisionEnter not working Unity3d 5
我的目标是在物体碰撞时改变物体颜色。
该对象本身是一个带有一些粒子效果的 capsuleCollider。
CapsuleCollider
正在跟踪玩家观看的位置。
telePoint.GetComponent<Rigidbody>().MovePosition(new Vector3(tempHit.point.x, player.transform.position.y, tempHit.point.z));
我尝试使用此脚本连接到玩家正在观看的对撞机 i 位置:
void OnCollisionEnter(Collision col) {
Debug.LogError("COLLISION ??" + col.gameObject.name);
if (!col.gameObject.name.Contains("floor")) {
player.GetComponent<telePortationScript>().teleEnabled = false;
}
else {
Debug.LogError("Collision with -> " + col.gameObject.name);
player.GetComponent<telePortationScript>().teleEnabled = true;
}
}
我正在移动的 CapsuleCollider
也有一个 RigidBody
组件并且启用了 Kinetic。其他对象只有碰撞器而没有刚体。
谁能帮帮我?
将我的 Capsule Collider 标记为 Trigger 并添加了一个函数
void OnTriggerStay(Collider col)
成功了!
我的目标是在物体碰撞时改变物体颜色。
该对象本身是一个带有一些粒子效果的 capsuleCollider。
CapsuleCollider
正在跟踪玩家观看的位置。
telePoint.GetComponent<Rigidbody>().MovePosition(new Vector3(tempHit.point.x, player.transform.position.y, tempHit.point.z));
我尝试使用此脚本连接到玩家正在观看的对撞机 i 位置:
void OnCollisionEnter(Collision col) {
Debug.LogError("COLLISION ??" + col.gameObject.name);
if (!col.gameObject.name.Contains("floor")) {
player.GetComponent<telePortationScript>().teleEnabled = false;
}
else {
Debug.LogError("Collision with -> " + col.gameObject.name);
player.GetComponent<telePortationScript>().teleEnabled = true;
}
}
我正在移动的 CapsuleCollider
也有一个 RigidBody
组件并且启用了 Kinetic。其他对象只有碰撞器而没有刚体。
谁能帮帮我?
将我的 Capsule Collider 标记为 Trigger 并添加了一个函数
void OnTriggerStay(Collider col)
成功了!