I'm creating a simple particle explosion but am stuck in finding the correct angle to rotate my particle. The effect I'm going for is similar to this:
Where each particle is going outwards from the point of origin and at the correct angle. This is what I currently have:
As you can see, each particle is facing the same angle, but I'm having a little difficulty figuring out the correct angle. I have the vector for the point of emission and the new vector for each particle, how can I use this to calculate the angle?
Some code for reference:
private Particle CreateParticle()
{
...
Vector2 velocity = new Vector2(2.0f * (float)(random.NextDouble() * 2 - 1), 2.0f * (float)(random.NextDouble() * 2 - 1));
direction = velocity - ParticleLocation;
float angle = (float)Math.Atan2(direction.Y, direction.X);
...
return new Particle(texture, position, velocity, angle, angularVelocity, color, size, ttl, EmitterLocation);
}
I am then using the angle created as so in my particles Draw method:
spriteBatch.Draw(Texture, Position, null, Color, Angle, origin, Size, SpriteEffects.None, 0f);