Quantcast
Channel: Latest Questions by eeveelution8
Viewing all articles
Browse latest Browse all 100

Script is causing immense lag, and I don't know what's causing it.

$
0
0
I have zombies in a game that fire mini projectiles at players, and have health scripts as well. I know it's one of their scripts because adding them to the game causes it to quickly become laggy, and then unplayable. this is the HP script, var HP : int = 5; var body : GameObject; var speed : int = 5; function Start () { body = gameObject; } function Update () { transform.Translate(Vector3(0,0,speed) * Time.deltaTime); if(HP < 1) { var instance : GameObject = Instantiate(body, transform.position, transform.rotation); DestroyObject (gameObject); } } function OnCollisionEnter (myCollision : Collision) { if(myCollision.gameObject.name == "zombieclimb"){ transform.Translate(Vector3(0,1,0) * Time.deltaTime); } } and the shooting script, var projectile : GameObject; var startdelay = 0.1; var delay = 0.1; InvokeRepeating("LaunchProjectile", startdelay, delay); function LaunchProjectile () { var instance : GameObject = Instantiate(projectile, transform.position, transform.rotation); } function Start () { projectile = gameObject; } Again, I don't know what is causing it, but I suspect it may be the Update function. Also, nothing appears in the console either.

Viewing all articles
Browse latest Browse all 100

Trending Articles



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