Hello, i am beginner to Unity (English too :))
I am trying to make someting and i am wondering is this correct way
I have a sample spaceship model in the center
When i click somewhere in the screen i want to move the ship to the that position and rotate it relative to clicked point (right top model is final position)
I solved the moving part with this code but i can’t rotate ship correctly
if (Input.GetMouseButton(1)) // Movement
{
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var start = ray.origin;
var destination = ray.origin + (ray.direction * 5);
Debug.DrawLine(start, destination, Color.blue, 10f);
float speed = ShipData.MaxSpeed;
transform.position = Vector2.MoveTowards(transform.position, destination, speed); // Move Ship
// Camera follow
var cam = Camera.main.transform.position;
Vector3 _cam = Vector3.Lerp(cam, transform.position, Time.deltaTime * 5);
_cam.z = cam.z;
Camera.main.transform.position = _cam;
}