Mouse position on a plane collider

Hello,

I want to generate an arrow when cliking 2 times with the mouse on a plane collider and use iTween to animate it after indicating the position of the base and the head arrow.
There is a input.mousePosition but it is relative to the screen and not the plane collider.
I will have 2 elements : the head of the arrow and the body. I will use the size of the body to animate.
The main issue is to locate the mouse on the ground.

Regards,

function Update () {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 300)) {
print(hit.point);}
}

// So you get the position where you clic

Hello,

Thanks Max II for the reply.
Everything works when I generate a prefab like a ball. I Want to animate an arrow :
first clic = generate the arrow head not visisble
second clic = generate the arrow base + start animation with (head + base) visible.
The second operation didn’t work properly. Any idea ?
Is there another method ?

What i want to achieve is every 2 clic I generate an new arrow.

Regards,


// arrow head + base objects
var arrowHeadA:GameObject;
var arrowBaseA:GameObject;

// start position + End position
var arrowPosStartA:Vector3;
var arrowPosEndA:Vector3;

// arrow On + mouse clic count
var arrowOn : boolean;
var nbClic : int = 0;

function Start()
{
arrowOn = false;
nbClic = 0;
}

function Update ()
{
// Construct a ray from the current mouse coordinates
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 300.0))
{
if (Input.GetButtonUp (“Fire1”) nbClic ==0)
{
// start position + intantiate arrow head not visible
arrowPosStartA = hit.point;
Instantiate(arrowHeadA, arrowPosStartA, Quaternion.identity);
arrowHeadA.renderer.enabled=false;
Instantiate(arrowBaseA, arrowPosStartA, Quaternion.identity);
arrowBaseA.transform.localScale=Vector3(9,9,0.15);
arrowBaseA.renderer.enabled=false;
nbClic++;
}
if (Input.GetButtonUp (“Fire1”) nbClic ==1)
{
// end position + intantiate arrow base head + animation visible
arrowPosEndA = hit.point;
arrowHeadA.transform.LookAt(arrowPosEndA);
arrowHeadA.renderer.enabled=true;
arrowBaseA.renderer.enabled=true;
iTween.moveTo(arrowHeadA, {“position”: arrowPosEndA , “time”:0.7, “transition”:“easeInOutQuint”});
iTween.scaleTo(arrowBaseA, {“Scale”:Vector3(9, 9, 9), “time”:0.7, “transition”:“easeInOutQuint”});
arrowOn = true;
nbClic++;
}
}
}