Game Freeze after hit second object [solved]

#1

hi i guess this problem in script i can send you the project to google drive

after i shoot and hit second or this sphere wich come from cube game not crash but it just freeze and not move

what wrong? wait i uploading project watch this

0 Likes

#2

download link of project https://drive.google.com/file/d/1UiMkw8HwGxC1nUoHfcE-VeOA8UeGX4fj/view?usp=sharing

0 Likes

#3

hi i find a solution on my computer this fire button was “space” i dont know why but it freeze i change fire button to other keyboard button “s” and game not freeze anymore reason was cheap keyboard

0 Likes

#4

so more exactly to script

one variation is freeze game and one not so this script not freeze game:

package arm;
import iron.system.Input;
import iron.system.Time;

class PlayerController extends iron.Trait {
private var fireSound:kha.Sound;
private var timeSinceLastFire = 0.0;
public function new() {
super();

	notifyOnInit(function() {
		iron.data.Data.getSound('laser.wav', function(soundFromDisk:kha.Sound){
            fireSound = soundFromDisk;
		});
	});

	notifyOnUpdate(function() {
		if(Input.getKeyboard().down("left")){
		    object.transform.translate(-5*Time.delta,0,0);
			object.transform.setRotation(0,-10,0);
			
		}
		if(Input.getKeyboard().down("right")){
			object.transform.translate(5*Time.delta,0,0);
			object.transform.setRotation(0,10,0);
		}
		if(!Input.getKeyboard().down("right") && !Input.getKeyboard().down("left")){
			object.transform.setRotation(0,0,0);

		}
		if(Input.getKeyboard().down("up")){
			object.transform.translate(0,5*Time.delta,0);
		}
		if(Input.getKeyboard().down("down")){
			object.transform.translate(0,-5*Time.delta,0);
		}

        function setBulletLoc(bullet:iron.object.Object){
			bullet.transform.loc.set(object.transform.loc.x,object.transform.loc.y,object.transform.loc.z);

		}

		//Fire bullets
		if(Input.getKeyboard().down("s")){
            if(timeSinceLastFire >= 0.2){
				iron.Scene.active.spawnObject("Bullet",null,setBulletLoc);
		    }
			timeSinceLastFire = 0.0;
			iron.system.Audio.play(fireSound);
		}
		timeSinceLastFire += Time.delta;{

		}
		if(Input.getKeyboard().started("space")){
			timeSinceLastFire = 10;
		}



	});

	// notifyOnRemove(function() {
	// });
}

}

and this script is freeze game when “space” is choosed on to variables

package arm;
import iron.system.Input;
import iron.system.Time;

class PlayerController extends iron.Trait {
private var fireSound:kha.Sound;
private var timeSinceLastFire = 0.0;
public function new() {
super();

	notifyOnInit(function() {
		iron.data.Data.getSound('laser.wav', function(soundFromDisk:kha.Sound){
            fireSound = soundFromDisk;
		});
	});

	notifyOnUpdate(function() {
		if(Input.getKeyboard().down("left")){
		    object.transform.translate(-5*Time.delta,0,0);
			object.transform.setRotation(0,-10,0);
			
		}
		if(Input.getKeyboard().down("right")){
			object.transform.translate(5*Time.delta,0,0);
			object.transform.setRotation(0,10,0);
		}
		if(!Input.getKeyboard().down("right") && !Input.getKeyboard().down("left")){
			object.transform.setRotation(0,0,0);

		}
		if(Input.getKeyboard().down("up")){
			object.transform.translate(0,5*Time.delta,0);
		}
		if(Input.getKeyboard().down("down")){
			object.transform.translate(0,-5*Time.delta,0);
		}

        function setBulletLoc(bullet:iron.object.Object){
			bullet.transform.loc.set(object.transform.loc.x,object.transform.loc.y,object.transform.loc.z);

		}

		//Fire bullets
		if(Input.getKeyboard().down("space")){
            if(timeSinceLastFire >= 0.2){
				iron.Scene.active.spawnObject("Bullet",null,setBulletLoc);
		    }
			timeSinceLastFire = 0.0;
			iron.system.Audio.play(fireSound);
		}
		timeSinceLastFire += Time.delta;{

		}
		if(Input.getKeyboard().started("space")){
			timeSinceLastFire = 10;
		}



	});

	// notifyOnRemove(function() {
	// });
}

}

0 Likes

#5

my god so happy it not freeze watch video https://youtu.be/OGCteR61Leg

0 Likes