I’m using this code to instantiate a projectile and get it to travel forward.
function Update ()
{
if(Input.GetButtonDown("Fire1"))
{
var starburstInstance : Rigidbody;
starburstInstance = Instantiate(starburstPrefab, starburstGunEnd.position, starburstGunEnd.rotation);
starburstInstance.AddForce(starburstGunEnd.forward * 2500);
audio.PlayOneShot(starburst);
}
}
All was fine until I added a hide cursor and add crosshair script. Now I suddenly realise that my targeting/aiming is way off.
How can I change (or replace) this line of code so the object will effectively travel towards where the crosshair was positioned and not just directly forwards?
starburstInstance.AddForce(starburstGunEnd.forward * 2500);
(Crosshair is positioned in center screen, attached to main camera)
Any ideas guys???