Automatic Shooting IF enemy is in range.. like DEAD trigger
sorry for English..........!!!!!! please Give me script in..the gun automatically start shooting if Player aims.... I am using RAYCAST shooting....
#pragma strict
var theDammage = 100;
function Update () {
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast (ray, hit, 100))
{
hit.transform.SendMessage("ApplyDammage", theDammage, SendMessageOptions.DontRequireReceiver);
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612105847im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Which Unity Tutorials should I watch? 0 Answers
Start Server or Join Existing Server as client automatically 0 Answers
How to restrict Y-axis value? 0 Answers
JavaScript function OnGUI error 1 Answer