so here is my shooting script i have it set to shoot forward but im having a hard time getting it to move the direction the camera is facing/ even have it fire from the camera direction view.
var shotSound : AudioClip; // drag a shot sound here, if any
var bloodPrefab : GameObject; // drag the blood prefab here, if any
var sparksPrefab : GameObject; // drag the sparks prefab here, if any
var crosshair : Texture2D;
function Start () {
//Screen.showCursor = false;
}
function OnGUI () {
GUI.DrawTexture(Rect(Screen.width/2 - 35,Screen.height/2 - 33,64,64), crosshair);
}
function Update () {
if(Input.GetMouseButtonDown(0)){
GetComponent.().RPC(“shoot”, RPCMode.All);
}
}
@RPC
function shoot () {
if (shotSound) GetComponent.().PlayOneShot(shotSound); // play the shot sound
var hit: RaycastHit;
if (Physics.Raycast(transform.position, transform.forward, hit))
{
// prepare rotation to instantiate blood or sparks
var rot = Quaternion.FromToRotation(Vector3.up, hit.normal);
if (hit.transform.tag == “Player”){ // if enemy hit…
if (bloodPrefab) Instantiate(bloodPrefab, hit.point, rot); // make it bleed…
//hit.transform.SendMessage(“ApplyDamage”, 5, SendMessageOptions.DontRequireReceiver); // and consume its health
hit.transform.GetComponent.().RPC(“ApplyDamage”, RPCMode.All, 5);
} else { // otherwise emit sparks at the hit point
if (sparksPrefab) Instantiate(sparksPrefab, hit.point, rot);
}
}
}
thanks for any help in advance…