- Home /
Question by
rhbrr5hrfgdfgw · Oct 12, 2013 at 02:56 PM ·
androidfpslow
Android fps problem.
The problem is that if you shoot (on a real android phone) using the gui button "shoot" the fps starting to be low. but if you stop shooting, after a second or 2 the fps is normal again. I even started a new scene to make sure there is no problem but it didn't help..
Gui script to shoot and zoom:
var scopeCam : GameObject;
var isInScope : boolean = false;
function OnGUI(){
if(GUI.RepeatButton(Rect(10,10,200,200),"Shoot")){
czShoot.shootOne = true;
}
if(GUI.Button(Rect(10,220,100,100),"Zoom")){
if(isInScope){
isInScope = false;
scopeCam.SetActiveRecursively(false);
}else if(!isInScope){
isInScope = true;
scopeCam.SetActiveRecursively(true);
}
}
}
A script called czShoot:
var bullets : GameObject;
var bulletE : GameObject;
static var shootOne : boolean = false;
var fireDelay : float;
var rateOfFire : float = 0.5;
var Ammo : int = 2000;
var bullet : Rigidbody;
var spawn : Transform;
var bulletShoot : AudioClip;
function Update(){
if(shootOne && Time.time > fireDelay){
if(Ammo > 0 && canFire){
shootOne = false;
fireDelay = Time.time + rateOfFire;
Instantiate(bullets, bulletE.transform.position, bulletE.transform.rotation);
Ammo--;
var bullet1 : Rigidbody = Instantiate(bullet, spawn.position, spawn.rotation);
bullet1.AddForce(transform.forward * bulletSpeed);
audio.PlayOneShot(bulletShoot);
Destroy(bullet1.gameObject, 5);
}
}
}
}
Comment
Is it possible, that the texture of the bullet is very highly detailed, so that it takes a lot of time to load?
No, but i think its because of the fire rate, and the reapeatButton.