I’m trying to create some kind of “sticky” projectiles with a sphere collider and a rigid body, by parenting them to the collider object in case of a collision. But a big number of them go through the objects, specially planes. I tried attaching the DontGoThroughThings script to the projectiles, but nothing changes, even modifing the skinWidth attribute. This is the code to parent the projectile:
void OnCollisionEnter(Collision collision) {
this.GetComponent<Rigidbody>().isKinematic = true;
this.transform.parent = collision.collider.transform;
}
If it helps in some way, here is the code I use to create the projectiles:
Vector3 shootDir = targetTransform.position - shootSourceTransform.position;
GameObject shuriken = Instantiate(Resources.Load("Prefabs/Gameplay/Shuriken"), shootSourceTransform.position, shootSourceTransform.rotation) as GameObject;
shuriken.rigidbody.AddForce(shootDir.normalized * Time.deltaTime * SHURIKEN_SPEED);
Is something I’m missing? Maybe I should try another way to check the collision?