How do I add a random direction +/-45 degrees of the direction the satellite is facing. That is, a random number between -45 and 45 should be added to its rotation. Along with a random impulse force between 0.25 and 3. This is my code so far.
// Add time since last call to Update
secondsSinceLast += Time.deltaTime;
// For each key, instantiate at position of this object (adjusted with an offset).
// and rotation of firing object. Then give force in the proper direction
if (secondsSinceLast >= secondsBetweenCoins)
{
GameObject p = Instantiate(projectile, // Offset forward
transform.position + transform.up * offset,
transform.rotation);
Rigidbody2D prb = p.GetComponent<Rigidbody2D>();
// Force forwards along local y axis
prb.AddRelativeForce(new Vector2(0, -force), ForceMode2D.Impulse);
// Reset timer
secondsSinceLast = 0;
}
}
}