void FixedUpdate()
{
var mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
var mouseDir = mousePos - gameObject.transform.position;
mouseDir.z = 0.0f;
mouseDir = mouseDir.normalized;
if (Input.GetKey(KeyCode.W))
{
rb.AddForce(mouseDir * speed);
}
if (Input.GetKey(KeyCode.A))
{
rb.AddForce(mouseDir * turnLeftSpeed);
}
if (Input.GetKey(KeyCode.D))
{
rb.AddForce(mouseDir * turnRightSpeed);
}
}
when I use this method to move my player to mouse direction It wont add force to its current position for example when the players position changed it adds force from the camera center I am not sure if I could explain it right but any kind of help will be okay thank you