In the image there is A and B. A wants to go towards B, but can only move in the same direction as the arrow on it. How could i find the direction A needs to face so that it points toward B? (like image 2)
Let’s assume in your game A is called ObjectA
And B is called ObjectB
Like that are their names in your object list
You can add force to B toward angle ObjectB.AngleToObject(ObjectA)
To move A to B add force to A toward angle ObjectA.AngleToObject(ObjectB)
You can add there INVERTED condition to check distance between two so they don’t stack on each other
This one you won’t need in this case but there is also ObjectName.AngleToPosition(X . Y)
For example Player.AngleToPosition(CursorX(),CursorY())
If you cannot reference object by name or you don’t have any
For example let’s check angle between center of screen and mouse cursor
Then there is AngleBetweenPositions(x1,y1,x2,y2)
Where 1 would be 1st position and 2 would be 2nd position
For example
AngleBetweenPositions(CameraCenterX(),CameraCenterY(),CursorX(),CursorY())
IN ALL scenarios pay attention angle from what to what you are checking
Let’s look at your 1st image
If you would check there ObjectA.AngleToObject(ObjectB)
You will get angle something like
135°
But angle form ObjectB.AngleToObject(ObjectA)
Would be something around -45°
It does not work both ways
It works from object/position that you name 1st in expression to object/position that is 2nd in expression
But i still would say adding force to object toward another object may be better solution for you
And your question about how to find angle between 2 objects was wrong
You should ask how to move 1 object toward another
Or maybe my fault for not thinking i should not answer your question and instead find you easier solution
WHATEVER
This should be easy enough for you to understand