Hi there! In my game, if a person is struck by lightning, then they die. The lightning spawns wherever the user clicks, and I don’t know how to check to see if the lighting bolt(which is instantiated) spawns near enough the person. The lightning bolt spawns at the x and z point of the click, and the y point has 100 added to it.
Here is my script to far (I know I misspelt the lightning variable):
var lightingBolt : GameObject;
var hit : RaycastHit;
var person : GameObject;
var distance = Vector3.Distance(lightingBolt.transform.position, person.transform.position);
function Update () {
if (Input.GetButtonDown ("Fire1")) {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, hit)) {
hit.point.y = hit.point.y + 100;
Instantiate (lightingBolt, hit.point, transform.rotation);
if(distance)
{}
}
}
}