So I created a plane to be my floor in my unity project. I also assigned that with a mesh collider and a box collider and set it with convex but not as trigger. I then created an item with also a mesh and sphere collider and set it to use gravity, since I wanted the item to fall onto the floor. But when I start the game, it still falling past the floor. I have tried to find a solution already in YT, here and other places, but the only ideas they give is assigning a collider. This doesn't work as for me. I also tried to fill the colliders with materials but cannot assign anything with it. I also tried to write a code, but this does not help either.
Does anyone have an idea how to solve it?
public class IsGrounded : MonoBehaviour
{
Vector3 velocity;
public float gravity = -9.81f;
public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
bool isGrounded;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
if (isGrounded && velocity.y < 0)
{
velocity.y = -2f;
}
}
}