Hello, I recently wrote a script for a 2D game that included jumping and it worked fine. I converted everything for 3D and made some edits so I could use 3D models for my platformer instead of sprites, however the script seems to be picking up collisions for child objects along with the main object.
The below is the part of the script that deals with collisions and is attached to the main object which is a capsule, I also have a child object that is a cube with no scripts attached however the main script is picking up collisions from the cube causing me to be able to stick to walls because my script thinks I am grounded, any ideas?
void OnCollisionStay(Collision coll){
/**
* This is for checking the tag of an object you are colliding with
* to see if it is a platform. If the tag is "Platform" then we set
* the variable isGrounded to true then break the switch, This was
* made a switch statement so more tags can be added later on.
**/
switch (coll.gameObject.tag)
{
case "Platform":
isGrounded = true;
Debug.Log("Grounded" + n);
n++;
break;
}
}
void OnCollisionExit(Collision coll){
/**
* When player stops colliding with a game objects it checks
* to see if isGrounded is true then, assuming it is, sets it to false.
**/
if(isGrounded){
isGrounded = false;
}
}