- Home /
When i use set fire1 to lose enemy health, doesnt lose any enemy health. Not sure if its binded to left click or not
Im watching brackeys tutorial for survival game and i set fire1 to do all this and that with a left clicking the mouse but it will not do anything. I am not sure if its binded to left click on mouse, i did go to the settings and it said left ctrl but i dont understand the settings. Yes im am new to Unity and programming. If you want the code for my enemy just ask. This is in java btw.
HERE IS MY CODE
#pragma strict
var TheDamage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
}
}
Answer by applemaniac · May 19, 2015 at 10:48 AM
Hello,
You should set fire1 to mouse 0 in your input settings, or, you can replace your if statement by OnMouseClick() function.
Your answer
Follow this Question
Related Questions
What is The Javascript name for "Left Mouse Click" 3 Answers
Setting Scroll View Width GUILayout 1 Answer
Activating an Animation? 2 Answers
Camera scripting references 0 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers