1
\$\begingroup\$

I'm creating spark particle effect so I created simple horizontal spark texture.

spark

Here is what I currently have

enter image description here

If I change rotation property, I get this

enter image description here

But i want to rotate particle to face the direction of movement. How can I achieve it?

I use libGDX Particle Editor.

\$\endgroup\$
1
\$\begingroup\$

Assuming you're using a Vector2 for your motion (or an x-speed and a y-speed variable), you just need to do a little trigonometry. To find the angle of travel, you take the arctangent of the y-speed divided by the x-speed. Let's call your motion vector "velocity." You can derive the angle by taking atan(velocity.y/velocity.x).

\$\endgroup\$
  • \$\begingroup\$ Yeah, but I use libGDX Particle Editor, not my own particles. And libgdx Vector2 has angle() method. \$\endgroup\$ – nikoliazekter Aug 29 '15 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.