I am trying to figure out a method to make my bullet destroy when it collides with the terrain. Right now, it will hit the terrain, and continue sliding across the ground until it’s life expectancy, and is then destroyed. Huge noob here, sorry for lack of further information. Any help would be greatly appreciated.
bullet.js
public var bulletPrefab : Transform;
public var bulletSpeed : float = 6000;
function Update ()
{
if (Input.GetKey(KeyCode.Mouse0))
{
if (!bulletPrefab || !bulletSpeed)
{
Debug.Log(“[Shoot] ‘bulletPrefab’ or ‘bulletSpeed’ is undefined”);
}
else
{
var bulletCreate = Instantiate(bulletPrefab, GameObject.Find(“SpawnPoint”).transform.position, Quaternion.identity);
bulletCreate.rigidbody.AddForce(transform.forward * bulletSpeed);
}
}
}
This seems to work fine, the bullet is destroyed after a preset time, but the collision for them to be destroyed when they hit the terrain is where I am stuck. Much thanks in advance for any suggestions.