どの値を設定する必要がありますか: 'setLinearVelocity(x, y);' プレイヤーの体の中心からマウスの位置まで撃ちたい場合は、オブジェクトの体に?
これらの変数を使用できます: mouseX、mouseY、playerX、playerY。
float velx = mouseX - playerX;
float vely = mouseY - playerY;
float length = Math.sqrt(velx * velx + vely * vely);
if (length != 0) {
velx = velx / length;
vely = vely / length;
}
float finalVelx = velx * speed;
float finalVely = vely * speed;
setLinearVelocity(finalVelx,finalVely);