void shoot() { shoot_sound.Play(); GameObject thing = Instantiate(bullet, aimingThing.transform.position, aimingThing.transform.rotation); bully = thing.GetComponent <bulletScript>(); bully.damage = damage; }
void shoot() { GameObject bulletShoot = (GameObject)Instantiate(bullet1, muzzle.position, muzzle.rotation); bulletScript bullet = bulletShoot.GetComponent <bulletScript>(); if (bullet != null) { bullet.seekTarget(currentTarget); } }
#pragma warning restore 414 void Awake( ) { #if !(UNITY_FLASH) useGUILayout = false; #endif ExposedVariables.Awake( ); ExposedVariables.SetParent(this.gameObject); if ("1.PLE" != uScript_MasterComponent.Version) { uScriptDebug.Log("The generated code is not compatible with your current uScript Runtime " + uScript_MasterComponent.Version, uScriptDebug.Type.Error); ExposedVariables = null; UnityEngine.Debug.Break(); } }
// Update is called once per frame void Update() { if (isFiring) { countdown -= Time.deltaTime; if (countdown <= 0) { countdown = bulletDelay; bulletScript bulletCloning = Instantiate(bullet, firePoint.position, firePoint.rotation) as bulletScript; bulletCloning.speed = bulletSpeed; } } else { countdown = 0; } }
void shoot(float yChange = 0f) { float lastDirection = player_movement.lastDirection; Quaternion laserRoation = transform.rotation; float width = GetComponent <SpriteRenderer>().bounds.size.x; if (lastDirection < 0) { width = -width; float angle = 180; laserRoation = Quaternion.AngleAxis(angle, Vector3.forward); } Vector2 spot = new Vector2(transform.position.x + (width / 2), transform.position.y + yChange); GameObject thing = Instantiate(bullet, spot, laserRoation); bully = thing.GetComponent <bulletScript>(); bully.damage = strength; bully.friendly = true; }
void Shoot(control.BulletParams bulletParams) { GameObject lastBullet = Instantiate(Resources.Load("bullet", typeof(GameObject))) as GameObject; if (lastBullet) { bulletScript lastBulletScript = lastBullet.AddComponent <bulletScript>() as bulletScript; lastBullet.transform.position = this.transform.position; lastBulletScript.bulletParams = bulletParams; lastBulletScript.bulletParams.speed = Random.Range(0.01f, 0.1f); lastBulletScript.bulletParams.color = Random.ColorHSV(); lastBullet.transform.position += new Vector3(bulletSpawnOffset.Rotate(this.angle).x, bulletSpawnOffset.Rotate(this.angle).y, 0.0f); } else { Debug.Log("could not instantiate bullet"); } }
// Update is called once per frame void Update() { if (!loading) { if (isFiring) { countdown -= Time.deltaTime; if (countdown <= 0 && currentAmmo > 0) { currentAmmo--; countdown = bulletDelay; bulletScript bulletCloning = Instantiate(bullet, firePoint.position, firePoint.rotation) as bulletScript; bulletCloning.speed = bulletSpeed; } } else { countdown = 0; } ammoBar.fillAmount = currentAmmo / ammoMax; } ammoBar.fillAmount = currentAmmo / ammoMax; }
public void take_damage(bulletScript bullet) { health -= bullet.damage; }
// Start is called before the first frame update private void Awake() { bulletScrpt = this; }
public bool shoot() { //Debug.Log("shoot() called."); //Debug.Log(gunName+ "I am asking it to play a sound " + gunName); FindObjectOfType <audioManager>().Play(gunName); MuzzleFlash.Play(); if (raycasting) { if (fpsCamera == null) { // fpsCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>(); } //Debug.Log("Oh yes raycasting time"); RaycastHit hit; if (Physics.Raycast(fpsCamera.transform.position, fpsCamera.transform.forward, out hit, range)) { //Debug.Log(hit.transform.name); //enemyScript enemy = hit.transform.GetComponent<enemyScript>(); //if(enemy != null) //{ // enemy.HurtEnemy(damage); //} playerHealth enemyPlayer = hit.transform.GetComponent <playerHealth>(); bool killedEnemy; if (enemyPlayer != null) { killedEnemy = enemyPlayer.hurtPlayer(damage); if (killedEnemy) { return(true); } } GameObject impac = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(impac, 1f); } } else { //This is bullet shooting // if (camTrans == null) { camTrans = GameObject.FindGameObjectWithTag("camera").GetComponent<Transform>(); } // gunSpawnTrans = GameObject.FindGameObjectWithTag("gunspawn").GetComponent<Transform>(); //gunSpawnTrans = bulletSpawn; GameObject bully; if (gunSpawnTrans != null) { Vector3 desiredPosition = gunSpawnTrans.position; //At the moment the bullet spawns in the middle of the gun, oh well WILL BE CHANGED LATER worry not bully = Instantiate(bullet, desiredPosition, camTrans.rotation); //And the bullet roation should follow the camera bulletScript bulletInstance = bully.GetComponent <bulletScript>(); bulletInstance.speed = speed; bulletInstance.damage = damage; bulletInstance.lifeTime = lifeTime; } else { Debug.Log("Oh man it looks like we can't find the desired position"); } } return(false); }