- Home /
Map disappears after couple seconds
I have no idea. I was trying out a rocket launcher script I found online (I haven't gotten it to work yet because I'm a scrub) and I got this really weird bug. After a couple seconds from launching the game, my whole map just disappears from the game screen (no collision nor textures) as well as from the hierarchy! I don't know if this is because of the scrpt or what, but I can not get the map to stay, how hard I try. Can anyone help me? These are the scripts I use (This was not made by me):
var radius : float = 5.0; //provides a radius at which the explosive will effect rigidbodies var power : float = 10.0; //provides explosive power var explosiveLift : float = 1.0; //determines how the explosion reacts. A higher value means rigidbodies will fly upward
function Start () {
Destroy(gameObject, 3);
}
function OnCollisionEnter (collision : Collision) {
var grenadeOrigin : Vector3 = transform.position;
var colliders : Collider[] = Physics.OverlapSphere (grenadeOrigin, radius); //this is saying that if any collider within the radius of our object will feel the explosion
for(var hit : Collider in colliders){ //for loop that says if we hit any colliders, then do the following below
if (hit.rigidbody){
hit.rigidbody.AddExplosionForce(power, grenadeOrigin, radius, explosiveLift); //if we hit any rigidbodies then add force based off our power, the position of the explosion object
Destroy(gameObject); //the radius and finally the explosive lift. Afterwards destroy the game object
}
}
}
var rocket : Rigidbody; //our prefab var throwPower : float = 10; //power variable determines how fast this object will be "shot out"
function Update () {
if (Input.GetButtonDown("Fire1")) {
var clone : Rigidbody; //variable within a variable
clone = Instantiate(rocket, transform.position, transform.rotation); //the clone variable holds our instantiate action
clone.velocity = transform.TransformDirection(Vector3.forward * throwPower); //applies force to our prefab using the "forward" position times our throwPower variable
}
}
Please, format your code using the "101 010" button.
Also, what scripts are attached to the map? Does it randomnly dissapear or always after the same amount of seconds?