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
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
download link of project https://drive.google.com/file/d/1UiMkw8HwGxC1nUoHfcE-VeOA8UeGX4fj/view?usp=sharing
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
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() {
// });
}
}