How would I get the crosshair perfectly accurate when I shoot.
How are you shooting (3D, 2D)? What kinds of accuracy problems are you having currently?
I am shooting in 3D. When I get the gun to line up with the cross hair at long range it is not lined up at close range when I shoot.
How are you implementing the gun? Ideally, could you post the script you are using for it?
The particle emitter attached to the gun.
var range = 100.0;
var bulletEffects : ParticleEmitter;
var flames : ParticleEmitter;
var gunSound : AudioSource;
function Update () {
if (Input.GetButtonDown("Fire1"))
{
HandGun();
}
if (Input.GetButtonDown("Fire2"))
{
flames.emit = true;
}
if (Input.GetButtonUp("Fire2"))
{
flames.emit = false;
}
}
function Start () {
Screen.lockCursor = true;
bulletEffects.emit = false;
flames.emit = false;
}
function HandGun () {
var hit : RaycastHit;
var direction = transform.TransformDirection(Vector3.forward);
if (Physics.Raycast (transform.position, direction, hit, range))
{
if (bulletEffects)
bulletEffects.transform.position = hit.point;
bulletEffects.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
bulletEffects.Emit();
}
if (hit.rigidbody)
{
var contacts = hit.rigidbody;
}
gunSound.Play();
}
i am having this problem too, i made an ak-47 and i am using the fps tutorial script.