Why object goes sometimes through walls by adding force ?

I want to throw a grenade (with Rigidbody and Collider). Therefore I use AddForce () and it is working. However if I throw the grenade, it sometimes goes through walls, even though the walls and the grenade have colliders. Please help me.

This is my code:

 using UnityEngine;
 using System.Collections;
 
 public class ThrowGrenade :MonoBehaviour
 {
     public GameObject grenadePrefab;
     public Transform grenadeSpawnPoint;
     public float throwForce = 20f;
     public float delay = 2f;
 
     void Update ()
     {
         if (Input.GetKeyDown (KeyCode.F))
         {
             GameObject go = Instantiate (grenadePrefab, grenadeSpawnPoint.position, grenadeSpawnPoint.rotation);
             go.GetComponent<Rigidbody>().AddForce (grenadeSpawnPoint.forward * throwForce, ForceMode.Impulse);
             Invoke ("Explode", delay);
         }
     }
 
     void Explode ()
     {
         //Explode
     }
 }

And sorry fro my bad English, because it isn’t my native language.

Have you tried setting the Collision Detection on the RigidBody on you grenade to something other than Discrete?

Sometimes, fast moving objects are able to move through other colliders. Generally, if you are having issues with fast moving objects and collisions, it is worth trying to set the Collision Detection to something other than Discrete.

Try to look at the documentation for RigidBody under Collision Detection: Unity - Manual: Rigidbody component reference

It’s working. Thank you very much :smiley:

In rigidbody component, change collision detection to continuous.