So, what I'm trying to do should be fairly simple, I have two characters, both have X and Y coordinates, I wish to calculate the angle between these two points and move an object from the first point to the second one.
When I looked around, I kept seeing this posted as the solution:
Where locationX and locationY is the start point and character.locationX and character.locationY is the destination point.
As I understand it, if I wish for a object to travel from the starting point of locationX, locationY I would do so by advancing with:
However, the actual result appears to be quite random...
When testing, the starting point remains the same and never change, whilst I move the end point around in the near area for the starting point, at times the starting point is aiming in the opposite direction, at times directly at it, but even then if I move the end point just a little bit to the left/right it starts aiming in a completely different direction, nowhere near correctly...
Any chance anyone here knows the proper form for my desired result? I'm at a complete loss as to what I'm doing wrong.
If there is any more code you wish to see, just ask and I'll provide it, however I don't think any other code is relevant to this issue since this is the only part meant to calculate the actual direction I'm after.
Oh, and to clarify:
aim, locationX and locationY are all variables of the type double, just in case that was important to know.