I basically have an object, which has two variables (X and Y)
Whenever I click the mouse, I call a method to move this object towards the Mouse's X and Y.
I don't have my code right now but it's something like this:
public float velX = 0;
public float velY = 0;
public void move(float mX, float mY){
//mX and mY represents the Mouse.getX() and Mouse.getY();
float x = this.getPosX();
float y = this.getPosY();
//Then, I try to get the angle.
float angle = Math.atan2 ( y - mY, x - mX ) * 57.2957795f; //57... is 180/pi
float scaleX = (float)Math.cos(angle);
float scaleY = (float)Math.sin(angle);
velX = scaleX * speed; //speed is already defined
velY = scaleY * speed;
//That's it, I created velX and velY
}
Then, in the Entity's loop, It moves itself using the velX and velY.
public void loop(){
posX += velX;
posY += velY;
}
//END
Everything on the code not-shown is fine, I can move the entity properly if I use set values for the velocities.
But if I try to get velocity from the
move() method, it gives weird results.
Basically, it doesnt work, the entity seems to move in a totally different way, instead of going in the direction of the mouse. It really doesnt make any sense.
I'm creating this topic after several tries to achieve this..
If you have any idea of how to do this, please, tell me

I just want to move the Entity in the direction of the mouse.
