|
-
var x:Number = 1; x /= 0;
well, you would have to get the angle that the car is facing and then the angle between the car and the object it hits. then take the difference of the two angles.
use something like
Code:
//detect angle between two objects
distOpp = Math.sqrt(Math.pow(mc2._x - mc2._x, 2)+Math.pow(mc2._y-mc1._y,2));
distAdj = Math.sqrt(Math.pow(mc2._x - mc1._x,2)+Math.pow(mc1._y-mc1._y,2));
hitLine2 = Math.atan2(distOpp, distAdj);
hitLine = (Math.PI*hitLine2)/180;
//that converts hitLine2 from radians to degrees
that uses the atan2 function to find the angle of the arc tangent of the two objects.
in other words...it finds the angle...
the problem is that the atan2 function only returns the angle from 0 - 90, so in each quadrant (saying that the x and y of mc1 are 0,0 on the coordinate plane) it only returns positive angles. You need to tell it to make the angle negative in the other quadrants.
2|1
-+-
3|4
vertical is 0 degrees and horizontal is 90 degrees, so in quadrant 1, 89 degrees is just above horizontal, and in quadrant 2, 89 degrees is just below horizontal.
Keep that in mind.
Then you can get the angle of the car using either the same formula...or just get the rotation.
I can't figure it all out right now, but play with that information until you get something...or don't get something.
Hope it helps...or doesn't help!
~Zippy Dee
Ted Newman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|