radians to vector?

Started by
4 comments, last by EvilNando 13 years, 9 months ago
Im trying to create a 2d vector to rotate my projectile

this is what Im doing

Vector2 aux = new Vector2((float)Math.Cos((double)radians), (float)Math.Sin((double)radians));

somehow it is not working as it should

any ideas?
Advertisement
Your code looks correct - that's generally how you would build a vector from an angle in 2-d.

Can you provide more details about the problem?
yeah sure

thing is my engine for drawing needs radians to handle sprite rotations


but my projectiles I need vector2 to be able to apply velocities in a proper fashion

the problem is that I get my image flipped in every case

when shooting to the left, upwards and to the right

(to left shot may seem correct but if you look closely you will notice the shading of the projectile is at the top )



Uploaded with ImageShack.us
what values are being passed when the odd behaviour is occurring?
for example when the angle is over 90 i get a radians value of 1.58 which is what I use to render the projectile
found it

problem was that I was flipping my texture depending of the vehicle facing

which I solved by simple over-rotating the projectile accordingly

the problem of that is that I have to make sure to draw the projectiles with another point of light in mind (looks wrong when set to top-bottom , maybe something like front to back or omni directional light might work )

This topic is closed to new replies.

Advertisement