Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- when i plant multiple bombs at a time, the explosion occurs on the position of the last bomb. a for loop would be a solution but i don't know apply the arrays on this code:
- function PlantBomb()
- {
- bombPos = transform.position + (transform.forward * 2);
- var theBomb = Instantiate(BombPrefab,bombPos,Quaternion.identity);
- newBombPos = bombPos;
- yield WaitForSeconds(2);
- Explode();
- Destroy(theBomb.gameObject);
- }
- function Explode()
- {
- Instantiate(ExplosionPrefab,bombPos,Quaternion.identity);
- yield WaitForSeconds(0.1);
- //BombPlanted -= 1;
- SpreadExplosion();
- }
- function SpreadExplosion()
- {
- expLocX = bombPos.x;
- expLocY = bombPos.y;
- expLocZ = bombPos.z;
- ExplosionLength = MaxExplosionLength * 2;
- SpreadPosX();
- SpreadPosZ();
- SpreadNegX();
- SpreadNegZ();
- }
- function SpreadPosX()
- {
- for (xx = expLocX + 2; xx < expLocX + ExplosionLength + 1; xx += 2)
- {
- var explosionXX = Vector3(xx,expLocY,expLocZ);
- Instantiate(ExplosionPrefab,explosionXX,Quaternion.identity);
- yield WaitForSeconds(0.1);
- }
- }
- function SpreadPosZ()
- {
- for (zx = expLocZ + 2; zx < expLocZ + ExplosionLength + 1; zx += 2)
- {
- var explosionZX = Vector3(expLocX,expLocY,zx);
- Instantiate(ExplosionPrefab,explosionZX,Quaternion.identity);
- yield WaitForSeconds(0.1);
- }
- }
- function SpreadNegX()
- {
- for (xz = expLocX -2; xz > expLocX - ExplosionLength - 1; xz -= 2)
- {
- var explosionXZ = Vector3(xz,expLocY,expLocZ);
- Instantiate(ExplosionPrefab,explosionXZ,Quaternion.identity);
- yield WaitForSeconds(0.1);
- }
- }
- function SpreadNegZ()
- {
- for (zz = expLocZ - 2; zz > expLocZ - ExplosionLength - 1; zz -= 2)
- {
- var explosionZZ = Vector3(expLocX,expLocY,zz);
- Instantiate(ExplosionPrefab,explosionZZ,Quaternion.identity);
- yield WaitForSeconds(0.1);
- }
- }
Add Comment
Please, Sign In to add comment