void GunMovement() { if (Input.GetKey(KeyCode.UpArrow)) { RotateGun(270); _bullet.Fire(Vector2.up, 0); } else if (Input.GetKey(KeyCode.LeftArrow)) { RotateGun(0); _bullet.Fire(Vector2.left, 90); } else if (Input.GetKey(KeyCode.DownArrow)) { RotateGun(90); _bullet.Fire(Vector2.down, 180); } else if (Input.GetKey(KeyCode.RightArrow)) { RotateGun(180); _bullet.Fire(Vector2.right, 270); } }
public void StartShooting() { if (bOT_Profile.blue == true) { transform.LookAt(target.transform); shootScript.Fire("water_pistol" + "_bullet", rayCastPos, 1400f, Vector2.one, PhotonNetwork.player, 25, false, -1); } if (bOT_Profile.red == true) { transform.LookAt(target.transform); shootScript.Fire("water_pistol" + "_bullet", rayCastPos, 1400f, Vector2.one, PhotonNetwork.player, 25, true, -1); } }
// Update is called once per frame void Update() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); // Zero refers to the first touch // touchPos is converted to world space, Unity co-ordinates, rather than pixel space Vector2 touchPos = Camera.main.ScreenToWorldPoint(touch.position); switch (touch.phase) { case TouchPhase.Began: // Calling Fire method shoot.Fire(touchPos); // Calculate offset between touch and object // Each variable represents the difference between touch position and object position deltaX = touchPos.x - transform.position.x; deltaY = touchPos.y - transform.position.y; break; case TouchPhase.Moved: // Object is moved in the same direction as finger using the calculated offset rb.MovePosition(new Vector2(touchPos.x - deltaX, touchPos.y - deltaY)); break; case TouchPhase.Ended: // Velocity and object is stopped rb.velocity = Vector2.zero; break; } } }
void Attack() { if (fire.timer <= 0) { // Use the Fire function on the Shoot script fire.Fire(); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.P)) { // Bitch here is where the magic happen ;) Shoot.Fire(_firepower); } }
void Attack() { // Check if the count down is less than or equal to 0 if (fire.timer <= 0) { // Use the Fire function on the Shoot script fire.Fire(); } }
public void OnFire() { if (!isShooting) { isShooting = true; shoot.Fire(transform.right, projectileSpawner.position, projectileObject); Invoke("ResetShoot", projectileComponent.FireDelay); } }
void Update() { horizontal = Input.GetAxis("Horizontal"); vertical = Input.GetAxis("Vertical"); jump = Input.GetButtonDown("Jump"); playerMovementScript.PlayerControls(horizontal, vertical, jump); shoot = Input.GetButtonDown("Fire1"); shootScript.Fire(shoot); }
void Fire() { if (cooldown > 0 || ammo <= 0) { return; } gunAnimator.SetBool("isFiring", true); if (currentWeapon.Slug == "flaregun") { actualGunAnimator.SetTrigger("fire"); } if (myParts != null && muzzleFlash != null) { myParts.Play(); muzzleFlash.intensity = muzzleFlashIntensity; } //PLAY AUDIO if (currentWeapon.Slug != "flamer") { GetComponent <PhotonView> ().RPC("PlayGunShot", PhotonTargets.All); } ammo--; currentWeapon.CurrentAmmo = ammo; ammoTxt.text = ammo.ToString(); cooldown = fireRate; // inaccuracyA should be set to currentWeapon.Accuracy Vector2 inaccuracyA = currentWeapon.Inaccuracy; // the 3rd variable is bullet speed, the 4th is x and y accuracy if (Input.GetMouseButton(1)) { // if in ironsights, reduce inaccuracy by 75% inaccuracyA = (inaccuracyA / 2) / 2; } // bulletSpeed should be set to currentWeapon.BulletSpeed float bulletSpeed = currentWeapon.BulletSpeed; int playerID = PhotonNetwork.player.ID; shootScript.Fire(inventory.equippedWeapon.Slug + "_bullet", bulletspawnPoss, bulletSpeed, inaccuracyA, PhotonNetwork.player, currentWeapon.Damage, team, playerID); }
private void Update() { if (!jump) { jump = Input.GetKeyDown(KeyCode.Space); } //if (Input.GetKeyDown(KeyCode.F)) //{ // shoot.Fire(); //} if (Input.GetKeyDown(KeyCode.F)) { if (ourShootType == ShootType.Flare && shoot.allowFire) { pressStartTime = Time.time; } } if (Input.GetKeyUp(KeyCode.F)) { if (ourShootType == ShootType.Flare && shoot.allowFire) { if (Time.time - pressStartTime < minChargeTime) { shoot.Fire(); } else { shoot.ChargeFire(); } } } // if (Input.GetKeyDown(KeyCode.L)) // { // shoot.LaserFire(); // } currentMovement.Move(horizontal, vertical, jump); }
// Update is called once per frame void Update() { fire.shellDamage = data.shellDamage; // Countdown fire.timer -= Time.deltaTime; // Check if the player is pressing the forwards key if (Input.GetKey(forwards)) { // Use the Forwards function on the TankMotor script motor.Forwards(); } // Check if the player is pressing backwards key if (Input.GetKey(backwards)) { // Use the Backwards function on the TankMotor script motor.Backwards(); } // Check if the player is pressing rotate left key if (Input.GetKey(rotateLeft)) { // Use the RotateLeft function on the TankMotor script motor.RotateLeft(); } // Check if the player is pressing rotate right key if (Input.GetKey(rotateRight)) { // Use the RotateRight function on the TankMotor script motor.RotateRight(); } // Check if the count down is less than or equal to 0 if (fire.timer <= 0) { // Check if the player is pressing space if (Input.GetKeyDown(shootShell)) { // Use the Fire function on the Shoot script fire.Fire(); } } }
// Update is called once per frame void Update() { // Countdown fire.timer -= Time.deltaTime; // Check if the player is pressing w or the up arrow if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) { // Use the MoveForward function on the TankMotor script motor.MoveForward(); } // Check if the player is pressing s or the down arrow if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) { // Use the MoveBackwards function on the TankMotor script motor.MoveBackwards(); } // Check if the player is pressing a or the left arrow if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) { // Use the RotateLeft function on the TankMotor script motor.RotateLeft(); } // Check if the player is pressing d or the right arrow if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) { // Use the RotateRight function on the TankMotor script motor.RotateRight(); } // Check if the count down is less than or equal to 0 if (fire.timer <= 0) { // Check if the player is pressing space if (Input.GetKeyDown(KeyCode.Space)) { // Use the Fire function on the Shoot script fire.Fire(); } } }
private IEnumerator HandleEngage(AttackCommand command) { soldierAnimator.SetBool("isShooting", true); var alien = shoot.Fire(); yield return(new WaitForSeconds(2)); if (alien) { //Need to show the corpse - we could render a sprite at the same position rather than changing the layer alien.layer = 0; if (alien.transform.childCount > 0) { var child = alien.transform.GetChild(0); child.gameObject.SetActive(true); child.gameObject.layer = 0; } } command.Completed = true; soldierAnimator.SetBool("isShooting", false); }
void Update() { shoot.Fire(this); }
private void FireAtPlayer() { shoot.Fire(transform.right.normalized, projectileSpawner.position, projectileObject); Invoke("ResetFire", projectileComponent.FireDelay); }