Here's an image. The stick figure represents the character or active object. Now, thinking that there's a vertical line across his torso, how do i find the angle between the arm and the line? perhaps, the image will explain better. 'x' is the angle i want to find. it would be best if i only have to use action point for it and not the hot spot. angle calculator?? advanced math??
You need an object that you set the the mouse's X and Y co-ordinates firstly, I'll call it MouseObject. This will calculate the angle in alterable value A of your character.
If X of MouseObject is Lower than X of Guy
---> Set alt value A to 180-ATan(((Y( "Guy" )-Y( "MouseObject" ))*1.0)/((X( "Guy" )-X( "MouseObject" ))*1.0))
If X of MouseObject is Greater than X of Guy
---> Set alt value A to 0-ATan(((Y( "Guy" )-Y( "MouseObject" ))*1.0)/((X( "Guy" )-X( "MouseObject" ))*1.0))
hmmm, that definitely helps somewhat. im not using the mouse though. i take it that if i replace the mouse commands with the 'hand' (action point), it should work right? thanks btw
its not. ill tell you what im doing. im trying to move a sword (rotate) when the hero moves his arm. this way i dont have to make animations for adding the sword. but the code you gave me, gives me answers in 0.0000 to 1.0000 degrees. or something a little more than that. so my sword just twitches :S the degrees should be more than 1 for it to move correctly :S could you tell me wt you are doing? do you have any idea how that could work?
oh n just for testing purposes, im moving a red box using keyboard around the hero and using the drawline object to see what the angle should look like.
ok, i got most of it working. i just had to mulitply the equation with 100 the only problem i have left now is that whenever i switch over from the positive to negative degrees (that you're equation gives me ), i get a jerk in the weapon for some reason. it goes back a few angles. so i cant really do a complete smooth 360 with it. and its very important that i do. do you know why that would be? btw, thanks a lot man. you're a genius perhaps, the problem with it for me is that you're equation is 180 degree based and i need 360 degrees. you convert the gradient between the points and convert it to degrees if im not mistaken, yes?
The equation Ben gave you returns a value in degrees (if you always get a number that's a lot smaller, than it's probably radians... or you just did it wrong ) Looking at Ben's equation, it all seems fine. If you don't want negative values, just add +90 everywhere.
If i remember rightly, it returns Atan as a value in radians.
pi radians=180 degrees
i.e if you multiply your returned Atan value by 180/pi it should return the correct angle in degrees.
haha, thanks a lot Joe. That fixed everything. and lol, I suppose studying would help defnitely. before Benothy told me his equation, I was trying to do this by using triangles. Had very little success with that. Anyway, you two are definitely gonna credit if my game is ever finished thanks!