Hey Leute,

Ich hätte gerne so wie auf dem Bild, dass das Projektil von einer Waffe zur Maus-Position fliegt. Ich habe schon ein bisschen gegoogelt und bisher das gefunden:
[CODE lang="java" title="Code"]pathX = xMouse - x;
pathY = yMouse - y;
double distance = Math.sqrt(pathX * pathX + pathY * pathY);
directionX = pathX / distance;
directionY = pathY / distance;
//Projektil Koordinaten
position.x +=directionX*delta*100;
position.y +=directionY*delta*100;[/CODE]
Es funktioniert irgendwie nicht richtig(siehe Bild).

Danke im Vorhinein.

Ich hätte gerne so wie auf dem Bild, dass das Projektil von einer Waffe zur Maus-Position fliegt. Ich habe schon ein bisschen gegoogelt und bisher das gefunden:
[CODE lang="java" title="Code"]pathX = xMouse - x;
pathY = yMouse - y;
double distance = Math.sqrt(pathX * pathX + pathY * pathY);
directionX = pathX / distance;
directionY = pathY / distance;
//Projektil Koordinaten
position.x +=directionX*delta*100;
position.y +=directionY*delta*100;[/CODE]
Es funktioniert irgendwie nicht richtig(siehe Bild).

Danke im Vorhinein.