Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Clone Scripts Freezes Unity On PlayMode!

$
0
0
I am making a FPS game and the AI just shoot constantly well the game is running. the Ai shoot script has worked for a while but today it freezes unity on play every time! this only happens with the green Ai shoot and not the Yellow Ai shoot script. GreenAI Shoot Script: public class GreenGun : MonoBehaviour { public Rigidbody bullet; public int bulletSpeed; public Transform GreenBotBarrel; public float destroySpeed = 0f; public int coolDown; // Use this for initialization void Start() { coolDown = 30; } void SpawnBullet() { Rigidbody b; b = Instantiate(bullet, new Vector3(GreenBotBarrel.position.x, GreenBotBarrel.position.y, GreenBotBarrel.position.z), GreenBotBarrel.rotation) as Rigidbody; b.AddForce(b.transform.forward * bulletSpeed); coolDown = 10; } // Update is called once per frame void Update() { coolDown -= 1; if (coolDown < 1) { SpawnBullet(); } } } YellowAi Shoot Script: using UnityEngine; public class YellowGun : MonoBehaviour { public Rigidbody bullet; public int bulletSpeed; public Transform YellowBotBarrel; public float destroySpeed = 0f; public int coolDown; // Use this for initialization void Start() { coolDown = 50; } void SpawnBullet() { Rigidbody b; b = Instantiate(bullet, new Vector3(YellowBotBarrel.position.x, YellowBotBarrel.position.y, YellowBotBarrel.position.z), YellowBotBarrel.rotation) as Rigidbody; b.AddForce(b.transform.forward * bulletSpeed); coolDown = 45; } // Update is called once per frame void Update() { coolDown -= 1; if (coolDown < 1) { SpawnBullet(); } } } I hope someone has an answer!

Viewing all articles
Browse latest Browse all 2383

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>