/** * At the end of the channel time, the player emits an attack prefab. */ public override void endChannel() { base.endChannel(); //Instantiate the fireball prefab Transform shotTransform = Instantiate(hitbox.transform) as Transform; //Adjust the positioning and the direction of the prefab shotTransform.position = playerInformation.transform.position; if (playerInformation.facingRight) { Vector3 playerScale = shotTransform.localScale; playerScale.x = playerScale.x * -1; shotTransform.localScale = playerScale; } //Modifies the projectileMovement controller that is attached to the projectile. projectileMovement move = shotTransform.gameObject.GetComponent <projectileMovement>(); shotController shotController = shotTransform.gameObject.GetComponent <shotController>(); shotController.ownerTag = this.transform.parent.gameObject.tag; if (move != null) { //moves the fireball in the direction of the Main Character if (playerInformation.facingRight) { move.direction = Vector2.right * projectileSpeed; } else { move.direction = Vector2.right * -1 * projectileSpeed; } } }
public override void endChannel() { base.endChannel(); for (int i = 0; i < bulletCount; i++) { Transform shotTransform = Instantiate(hitbox.transform) as Transform; shotTransform.position = playerInformation.transform.position; if (playerInformation.facingRight) { Vector3 playerScale = shotTransform.localScale; playerScale.x = playerScale.x * -1; shotTransform.localScale = playerScale; } projectileMovement move = shotTransform.gameObject.GetComponent <projectileMovement>(); AirBulletsHitBox shotController = shotTransform.gameObject.GetComponent <AirBulletsHitBox>(); shotController.ownerTag = this.transform.parent.gameObject.tag; if (move != null) { float angle = Random.value * MaxAngle; if (Random.value > .5) { angle = angle * -1; } if (playerInformation.facingRight) { move.direction = new Vector2(projectileSpeed, projectileSpeed * Mathf.Tan(Mathf.Deg2Rad * angle)); } else { move.direction = new Vector2(-1f * projectileSpeed, projectileSpeed * Mathf.Tan(Mathf.Deg2Rad * angle)); } } } }