so i have a script where it draws an arrow from a ball showing the power and direction in which the ball will go according to the mouse positions on the screen. everything works as intended but i have a small bug where when the arrow gets instantiated the arrow first flickers for about 1 frame where the arrow has no rotation, so it shows itself just being drawn horizontally across the screen then after that it changes its size and rotation properly according to the mouse positions.
if (Input.GetKey (KeyCode.Mouse0)) {
if (isMoving == false) {
ShotDirection ();
}
void ShotDirection(){
if (arrow == null) {
arrow = Instantiate (Resources.Load ("Arrow 1")) as GameObject;
}
Vector2 ballPos = Camera.main.ScreenToWorldPoint (transform.position);
float angle = AngleBetweenTwoPoints (startPosition, mousePos);
arrow.transform.rotation = Quaternion.Euler(new Vector3(0f,0f,angle));
arrow.transform.localScale = new Vector3 (1, mouseDist, 1);
arrow.transform.position = gameObject.transform.position;
}