I was making a gun script with JavaScript. I came across this issue and it has me confuzzled lol. I am fairly new to Unity so help will be greatly appreciated. I have my script listed below:
#pragma strict
var bulletTex : GameObject[];
function Start () {
}
function Update () {
var fwd : transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;
Debug.DrawRay(transform.position, fwd * 40, Color.red);
if(Input.GetButtonDown ("Fire1") Physics.Raycast(transform.position, fwd, hit, 40)){
Instantiate(bulletTex[Random.Range(0,2)], hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));
}
}