Raycast length or camera to between mousePosition and character

Hello guys,
i have simple question. in my game project i will use camera script that positioning between cursor and character. can i use length/2 of my raycast or what can i use? can you answer me in simply? thanks a lot guys… (the game is 2d perspective and processing in z=0 so character, cursor and bullets , all moving on just x and y axes.)

(EDIT1: in my platform game, my cahracter will cast a Fireball spell to direction of a cursor,mouse position. also my camera will focus to show between character and cursor. I mean smiliar to Soldat patform shooter game’s camera style.)

If I understand the question then you can do this quite simply using:

var MousePos : Vector3;
var CharObject : Transform;

function Update () {
	MousePos = Camera.main.ScreenToWorldPoint(Vector3(Input.mousePosition.x, Input.mousePosition.y, -transform.position.z));
	transform.position.x = ((MousePos.x - CharObject.position.x)/2.0)+CharObject.position.x;
	transform.position.y = ((MousePos.y - CharObject.position.y)/2.0)+CharObject.position.y;

What I understood was that you want the camera to be centred between your character and your mouse position.
This will work if you set ‘CharObject’ to your character model, though I have not included any clamping of the mouse position so this will work best in fullscreen at the moment, though clamping would be easy to add.

Hope that helps,