zylum
1
basically i have two movie clips. i know the x diff and the y diff, now how do i find the angle at which the movie clips are at?
v MC 2
/|
/ |
/ | < y diff
/ |
MC 1 > /__|
^ \
angle x diff
i hope that’s clear enough
-mike
ooops, the diagram got screwed up when i posted…
eh, i sort of fixed it for you…
rad_deg = Math.PI / 180;
angle = Math.atan2 (y_diff, x_diff);
angle /= rad_deg; //to convert to degrees
note: hope u know about CAST rule, cuz u need
maybe try reading about Math.atan also…
i tried that and it didn’t work. i probably didn’t do it right. here’s my script:
[AS]diffx = MC1._x - MC2._x
diffy = MC1._y - MC2._y
ang = Math.atan2(diffx, diffy);
this.dx = Math.cos(this.ang)*this.speed;
this.dy = Math.sin(this.ang)this.speed;
this._x += this.dx;
this._y += this.dy;
this._rotation = this.ang(180/Math.PI);[/AS]
i want MC1 to move towards MC2. maybe my approach is totaly wrong…:-\
oh, yeah, the above script is in an onEnterFrame function and all that it does is make MC1 move to the right horizontaly
ummm, do u know about the CAST rule?
nope, is it important? if it is can you please give a brief explanation? thatnks
system
10
S | A
|_
T | C
C: cosine
A: all
S: sine
T: tangent
these are the quadrant that are positive
system
11
ahh… nevermind, simple scripting error, your way works. thanks a lot 