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\$

2 Answers 2

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\$
1
  • \$\begingroup\$ Yeah, but I use libGDX Particle Editor, not my own particles. And libgdx Vector2 has angle() method. \$\endgroup\$ Aug 29, 2015 at 7:30
0
\$\begingroup\$

It works with "aligned" option, but you need to set only one value in angle settings chart.

enter image description here

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .