-
Am I doing this right?
I am trying to teach myself how to use expressions (with a lot of help from this forum I should add).
One thing I’ve needed to do several times in my projects is to work out the direction that something is traveling at any point in time so I can adjust and other property or object accordingly. In the case bellow I have set up a particle emitter to move around the screen and I wanted the angle of the emitter to change so that it looks like the tail of a firework or something. I haven’t come across a straight forward way of doing this so I’ve done the following:
old_pos=effect(“Particle Playground”)(“Position”).valueAtTime(time-0.2);
new_pos=effect(“Particle Playground”)(“Position”);
y_was=old_pos[1];
x_was=old_pos[0];
y_is=new_pos[1];
x_is=new_pos[0];
y_dif=(y_was-y_is);
x_dif=(x_was-x_is);
angle=Math.atan2(y_dif, x_dif);
deg_angle=radiansToDegrees(angle);
[deg_angle+90];This works well but is it the simplest way of doing this or is there an easier way?
Thanks
Conrad