|
-
Apr 14th, 2002, 11:40 AM
#1
Thread Starter
Lively Member
-
Apr 14th, 2002, 12:05 PM
#2
First, you need to construct a facing vector. Take the point that the mouse clicked on, and subtract from it the position of the character:
Code:
Type vector
x as Single
y as Single
End Type
...
Dim mouseClick as vector
Dim charPos as vector
...
Dim facing as vector
facing.x = mousePos.x - charPos.x
facing.y = mousePos.y - charPos.y
Now that you have a facing vector, you can use an arctangent to find the facing angle:
Code:
Dim faceAngle as Single
faceAngle = atn(facing.y/facing.x)
The above code will NOT give you the correct angle under certain circumstances (if facing.x is 0, if facing.x or facing.y is negative), but it should get you started.
Z.
[edit]
faceAngle will also be in radians, with the code above. Multiply it by (180 / 3.14159) to get the actual angle in degrees.
-
Apr 14th, 2002, 12:10 PM
#3
Thread Starter
Lively Member
Ich widerstehe allem - nur nicht der Versuchung
(I can resist anything but temptation)
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
|