I’m using this code to detect the collision between my player and “Cloud” gameObject. Funnily enough this code:
function OnControllerColliderHit(hit : ControllerColliderHit) {
if (hit.collider.gameObject.name == "Cloud") {
print(this.hit.collider.gameObject.name);
}
}
prints “Plane” in the debugger, which is not the behavior I’m looking for. Clearly the Collider must be detecting both the Plane and the Cloud (that cloud is sitting on a plane). How can I make sure that I’m taking the Collider with the Cloud and not the plane.
IE: make sure this hit.collider.transform = Vector3(0,0,0) would affect the cloud and not the plane.
Many thanks that indeed did it. Didn't even try that. Could you explain why this.hit != hit in this context? I thought 'this' would be unnecessary, but refer to the same hit?
– alexkaskasoli