// Update is called once per frame void Update() { // update speed of engine float speedX = 0; if (Input.GetAxis("Horizontal") > 0) { speedX = 1; } else if (Input.GetAxis("Horizontal") < 0) { speedX = -1; } float speedY = 0; if (Input.GetAxis("Vertical") > 0) { speedY = 1; } else if (Input.GetAxis("Vertical") < 0) { speedY = -1; } _engine.Speed = new Vector2(speedX, speedY).normalized; if (Input.GetAxis("Fire1") > 0) { _bulletGun.Fire(); } }
// Update is called once per frame void Update() { //engines.Speed = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); if (Input.GetAxis("Horizontal") > 0) { engines.Speed = new Vector2(1, engines.Speed.y); } else if (Input.GetAxis("Horizontal") < 0) { engines.Speed = new Vector2(-1, engines.Speed.y); } else { engines.Speed = new Vector2(0, engines.Speed.y); } if (Input.GetAxis("Vertical") > 0) { engines.Speed = new Vector2(engines.Speed.x, 1); } else if (Input.GetAxis("Vertical") < 0) { engines.Speed = new Vector2(engines.Speed.x, -1); } else { engines.Speed = new Vector2(engines.Speed.x, 0); } if (Input.GetButton("Fire")) { bulletGun.Fire(); } }
// Update is called once per frame void Update() { Vector2 movement = new Vector2(Input.GetAxis("Horizontal") * playerAvatar.MaxSpeed, Input.GetAxis("Vertical") * playerAvatar.MaxSpeed) * Time.deltaTime; Vector2 finalMovement = new Vector2(0, 0); if ((transform.position.x + movement.x > marginLeft) && (transform.position.x + movement.x < marginRight)) { finalMovement.x = movement.x; } if ((transform.position.y + movement.y > marginBottom) && (transform.position.y + movement.y < marginTop)) { finalMovement.y = movement.y; } engines.Speed = finalMovement; timeCount += Time.deltaTime; if (Input.GetButton("Fire1") && (timeCount > bulletGun.Cooldown) && (playerAvatar.CurrentStatus == 0)) { bulletGun.Fire(); timeCount = 0; } else if (timeCount > 1.0f) { if (playerAvatar.CurrentEnergy < 1) { playerAvatar.CurrentEnergy += playerAvatar.CostEnergy / 2; } } }
// Update is called once per frame void Update() { transform.position = enemyController.Position; if (enemyController.Fire) { bulletGun.Fire(); enemyController.Fire = false; } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { _bulletGun = GetComponent <BulletGun>(); _bulletGun.Fire(); } float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); _engine.Speed = new Vector2(moveHorizontal, moveVertical); }
public void Fire(string type) { BulletGun bulletGun = FindBulletGun(type); if (bulletGun) { if (Time.time - lastFire >= rate) { lastFire = Time.time; bulletGun.Fire(); } } }
void Update() { CheckInput(); engine.SetDirection(new Vector2(horInput, verInput)); if (changeInputpressed) { bulletGun.ChangeBulletType(); } if (fireInput > 0) { bulletGun.Fire(); } else { bulletGun.NotFire(); } }
void Update() { float _horizontal = Input.GetAxisRaw("Horizontal"); float _vertical = Input.GetAxisRaw("Vertical"); _player.transform.Translate(_speed * new Vector2(_horizontal, _vertical)); if (_player.transform.position.y > 3.3f) { _player.transform.position = new Vector2(_player.transform.position.x, 3.3f); // Remplacer Screen.height par l'equi en world space } else if (_player.transform.position.y < -4.5) { _player.transform.position = new Vector2(_player.transform.position.x, -4.5f); } if (Input.GetKey(KeyCode.Space)) { _bulletGun.Fire(); } }