protected override void formatSpawn(Castable spawn) { float angle = -Mathf.Deg2Rad * UnityEngine.Random.Range(0, 180); //The y-coordinate in the rotation formula is not necesarry as we're rotating from <-1, 0> (Vector2.left) float x = -1 * Mathf.Cos(angle); float y = -1 * Mathf.Sin(angle); spawn.GetComponent <Rigidbody2D> ().velocity = new Vector2(x * Speed, y * Speed); }
protected void formatSpawn(Castable spawn) { spawn.AssignModifier(damageModifier); //Move bolt to top of volcano spawn.transform.position = transform.position + new Vector3(0, 1.5f); //Calculate a random direction to shoot the bolt. float angle = -Mathf.Deg2Rad * UnityEngine.Random.Range(0, 180); //The y-coordinate in the rotation formula is not necesarry as we're rotating from <-1, 0> (Vector2.left) float x = -1 * Mathf.Cos(angle); float y = -1 * Mathf.Sin(angle); spawn.GetComponent <Rigidbody2D> ().velocity = new Vector2(x * Speed, y * Speed); }