Not registering OnCollisionEnter?
Hello all,
I am trying to turn on a Boolean if the player is colliding with certain objects. In the update class, the "currentName" variable is set dependent on what is happening in the game. I have the debug log printing out the currentName every time it changes and this is working perfectly fine but the Boolean never changes even when the player is clearly colliding. Firstly, does this code look correct? Secondly, should this snipit be before the update code or after, does it matter?
To start with, I did have col.gameObject.name instead of col.collider.name but this did nothing. I have also tried just OnCollision but this also did not work.
void OnCollisionEnter (Collision col) {
if (col.collider.name == currentName) {
collisionCheck = true;
}else {
collisionCheck = false;
}
}
dfffgg
Check if both the gameobjects have rigidbodies and collider attached to it. Also check if rigidbody dont have Is$$anonymous$$inematic check.
If both the above things are proper than it should work without any hiccups.
Your answer