I am researching about TPS cameras . If i use LookAt(target), player stands in the middle of view and crosshair on it. GTA5, Just Cause 2 have nice cameras. Player model stands on bit left side. You can rotate around them with camera and crosshair is in the middle. How can i put player on left side in any amount with a variable?
Vector3 cameraOrientationVector= new Vector3(1,0,-2);
public float crosshairSize;
public Transform target;
public Texture2D crosshairImage;
public float turnSpeed=5f;
private Vector3 offsetX;
private Vector3 offsetY;
void Start ()
{
offsetX = new Vector3 (10, 0, -2);
offsetY = new Vector3 (10, 0, -2);
}
void OnGUI()
{
float xMin = (Screen.width / 2) - (crosshairImage.width / 2);
float yMin = (Screen.height / 2) - (crosshairImage.height / 2);
Rect position = new Rect((Screen.width - crosshairSize) * 0.5f, (Screen.height - crosshairSize) * 0.5f, crosshairSize, crosshairSize);
GUI.DrawTexture(new Rect(xMin, yMin, crosshairImage.width, crosshairImage.height), crosshairImage);
}
void LateUpdate ()
{
offsetX = Quaternion.AngleAxis (Input.GetAxis("Mouse X") * turnSpeed, Vector3.up) * offsetX;
offsetY = Quaternion.AngleAxis (Input.GetAxis("Mouse X") * turnSpeed, Vector3.right) * offsetY;
transform.position = target.position + offsetX;
transform.LookAt(target); // so crosshair on player
//transform.position = target.position + cameraOrientationVector;
}