How can I make objects unable to pass each other?
eg. Bullet going though a plane at a high velocity.
How can I make objects unable to pass each other?
eg. Bullet going though a plane at a high velocity.
I advice you (but that can be quit performance heavy) to use a lineCast.
To make short, the physics engine check if the object is into a collision an replace it if it is in. As your bullet is reallly fast mainly compared to its size, unity does not detect the collision.
Rec the position on the frame before and make a linecast (that ignore the bullet) between the position before and after
// Not been tested, created on the fly
private var posBef : Vector3 = transform.position;
function FixedUpdate() { //Called at each physics calculation so that'll make the line called at the right time
var pos : Vector3 = transform.position;
var hit : RaycastHit;
if (Physics.Linecast(posBef, pos, hit, /*environment layer*/)) { // be carefull quite performance heavy mainly called 50times per seconds
transform.position = hit.point; // replace bullet at collision
transform.rigidbody.velocity = Vector3.zero; // Set speed of bullet to 0 to stop it (even changing position keep speed)
Do();// do whatever you want with hit.collider which represent the collider you hit
}
posBef = pos; // Rec the actual pos to use it on next FixedUpdate
}
That could give something like that.