How to get angle from unit to mouse click?

Hi, I can’t figure out how to get an angle between unit and mouse click. I need it in C#.
Angle from charactercontroller which is casting the spell to point where i clicked while ago by mouse.
[24924-simple+thing.png|24924]

Can you get it now? :stuck_out_tongue: I cast a spell (C# trigger) and i want to get this angle.

Is THIS what you’re lookin’ for? :slight_smile: I typed it up in Windows Sticky Notes so I’m absolutely unsure as to if this works. It’s along the lines of what you’re trying to do though.

#pragma strict
var projectile:GameObject;
var projectileSpeed:float=10;

if (Input.GetMouseButtonDown(0)){
  var touchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
  var shootDir = new Vector3(transform.position.x - touchPosition.x,  transform.position.y - touchPosition.y , transform.position.z - touchPosition.z);
  shootDir.Normalize();
  strike(shootDir);
}

function strike(shootDir : Vector3){
  var rotation1 = Quaternion.LookRotation(shootDir);
  var projectile = Instantiate(projectilePrefab, Vector3(transform.position.x,transform.position.y,transform.position.z), rotation1);
  projectile.rigidbody.velocity = projectile.transform.up*-projectileSpeed;
}

Well… Nevermind… You want it in C# =/

i guess it’s the same question