Move towards fails Slick2d
Vector2f move = new Vector2f(0, 0);
float mAngle = (float) Math.atan2(target.getY() - position.getY(), target.getX() - position.getX());
move.x = (float) Math.cos(mAngle) * speed;
move.y = (float) Math.sin(mAngle) * speed;
System.out.println("MOVEX: " + move.x + " MOVEY " + move.y);
return move;
That is my function for moving toward. The target position is 0,0 aka left-top of white background). After that i add Vector move to velocity of bullet. however at some point, when ether x or y are less than 1.0 or -1.0 the bullet object start to act unexpected. Any tips where the problem could be?
Vector2f move = new Vector2f(0, 0);
float mAngle = (float) Math.atan2(target.getY() - position.getY(), target.getX() - position.getX());
move.x = (float) Math.cos(mAngle) * speed;
move.y = (float) Math.sin(mAngle) * speed;
System.out.println("MOVEX: " + move.x + " MOVEY " + move.y);
return move;
That is my function for moving toward. The target position is 0,0 aka left-top of white background). After that i add Vector move to velocity of bullet. however at some point, when ether x or y are less than 1.0 or -1.0 the bullet object start to act unexpected. Any tips where the problem could be?
No comments:
Post a Comment