What is the formula/logic to implement moving an object towards a TOUCHED location. I want character A to move to my finger and it must be accurate. Here is what I have tried so far:
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
// coordinates come in pixels so convert to world units
scaleX = screenX / (Gdx.graphics.getWidth() / 10f);
scaleY = screenY / (Gdx.graphics.getHeight() / 7f) * -1;
float angle = new Vector2(scaleX - mishi.getPosition().x, scaleY
- mishi.getPosition().y).angle();
....
....
mishi.getVelocity().x = (float) (Math.cos(angle) * 13);
mishi.getVelocity().y = (float) (Math.sin(angle) * 13);
This gets my character moving but basically no where in the direction I click. If I click in the same point twice, it will move him in 2 different directions