void Update() { if (Input.GetButtonDown("Fire")) { // TODO: Shoot a bullet! // Instantiate it and get a reference of its Bullet Component. // You're going to need it ;) var bullet = Instantiate(mBulletPrefab, transform.position, transform.rotation).GetComponent <Bullet>(); bullet.name = mBulletPrefab.name; // TODO: Set the direction of the bullet // Use the SetDirection() function from the Bullet class bullet.SetDirection(mMegaManRef.GetFacingDirection()); // TODO: Play the mBusterSound! mBusterSound.Play(); // Set animation params mShooting = true; mTime = 0.0f; } if (mShooting) { mTime += Time.deltaTime; if (mTime > kShootDuration) { mShooting = false; } } UpdateAnimator(); }
void Update() { if (Input.GetButtonDown("Fire")) { GameObject bulletObject = Instantiate(mBulletPrefab, transform.position, Quaternion.identity ); Vector2 bulletdirection = mMegaManRef.GetFacingDirection(); Bullet cc = bulletObject.GetComponent <Bullet>(); cc.SetDirection(bulletdirection); mBusterSound.Play(); mShooting = true; mTime = 0.0f; } if (mShooting) { mTime += Time.deltaTime; if (mTime > kShootDuration) { mShooting = false; } } UpdateAnimator(); }
void Update() { if (Input.GetButtonDown("Fire")) { GameObject bulletObject = Instantiate(mBulletPrefab, transform.position, Quaternion.identity); //Call instantiate Bullet bullet = bulletObject.GetComponent <Bullet>(); bullet.SetDirection(mMegaManRef.GetFacingDirection()); // and using MegamanRef GetFacingDirection() function // Set animation params mShooting = true; mTime = 0.0f; } if (mShooting) { mTime += Time.deltaTime; if (mTime > kShootDuration) { mShooting = false; } } UpdateAnimator(); }
void Update() { if (Input.GetButtonDown("Fire")) { // TODO: Shoot a bullet! // Instantiate it and get a reference of its Bullet Component. // You're going to need it ;) GameObject newBullet = Instantiate(mBulletPrefab); newBullet.transform.position = this.transform.position; Bullet bulletScript = newBullet.GetComponent <Bullet>(); // TODO: Set the direction of the bullet // Use the SetDirection() function from the Bullet class Vector2 megaManDirection = mMegaManRef.GetFacingDirection(); bulletScript.SetDirection((megaManDirection == EMPTY_VECTOR ? DEFAULT_DIRECTION : megaManDirection)); // TODO: Play the mBusterSound! mBusterSound.Play(); // Set animation params mShooting = true; mTime = 0.0f; } if (mShooting) { mTime += Time.deltaTime; if (mTime > kShootDuration) { mShooting = false; } } UpdateAnimator(); }
void Update() { if (Input.GetButtonDown("Fire")) { // Shoot bullet GameObject bulletObject = Instantiate(mBulletPrefab, transform.position, Quaternion.identity) as GameObject; Bullet bullet = bulletObject.GetComponent <Bullet>(); // Set direction of bullet bullet.SetDirection(mMegaManRef.GetFacingDirection()); // Set animation params mShooting = true; mTime = 0.0f; // Play sound mBusterSound.Play(); } if (mShooting) { mTime += Time.deltaTime; if (mTime > kShootDuration) { mShooting = false; } } UpdateAnimator(); }
void Update() { if (Input.GetButtonDown("Fire")) { // TODO: Shoot a bullet! // Instantiate it and get a reference of its Bullet Component. // You're going to need it ;) GameObject bulletObject = Instantiate(mBulletPrefab, transform.position, Quaternion.identity); //Call instantiate // Bullet bullet = //Get the Bullet Component // TODO: Set the direction of the bullet // Use the SetDirection() function from the Bullet class // and using MegamanRef GetFacingDirection() function Vector2 bulletdirection = mMegaManRef.GetFacingDirection(); Bullet Boo = bulletObject.GetComponent <Bullet>(); Debug.Log("dir" + bulletdirection); Boo.SetDirection(bulletdirection); // TODO: Play the mBusterSound! mBusterSound.Play(); // Set animation params mShooting = true; mTime = 0.0f; } if (mShooting) { mTime += Time.deltaTime; if (mTime > kShootDuration) { mShooting = false; } } UpdateAnimator(); }