So I have a script which is my modification of Brackeys Raycasting shooting script and all I want is for my raycast to do 20 damage to an enemy but even if I change the "TheDammage" variable at the top nothing happens. It still only does 10 damage to an enemy per hit. 10 clicks is way too much to kill someone so I ask of you, please help me get my enemies to die in 5 clicks. Also there is no error either its just not right. Info: Enemy has 100hp, locked damage is 10dmg, what I want is 20dmg (5 clicks of the mouse button) Heres my script: Code (JavaScript): #pragma strict var TheDammage = 20; var bulletHole : GameObject; var bullets : int; function start() { bullets = 10; } function Update() { Screen.showCursor = false; var fwd = transform.TransformDirection(Vector3.forward) * 150; var hit : RaycastHit; var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0)); if (Input.GetMouseButtonDown (0) && Physics.Raycast(transform.position, fwd, hit, 10)) { if (hit.transform.tag == "Prop" && bullets > 0) { var bulletHoleClone = Instantiate(bulletHole, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)); Destroy(bulletHoleClone.gameObject, 10); } } if (Input.GetMouseButtonDown(0) && bullets > 0) { bullets -= 1; if (Physics.Raycast (ray, hit, 100)) { hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver); } } if (Input.GetKeyDown(KeyCode.R)) { ReloadTheGun(); } } function ReloadTheGun() { yield WaitForSeconds (0.8); bullets = 10; }
btw, i have no idea what locked damage is 10dmg means, but could it be a "damage cap" ?! in which case it negates the 20dmg as its capped at 10 dmg... ofcourse i dont know the rest of the code so i can only guess.
By locked damage Im talking about the damage the script will only do even if I change the dammage variable Do you want to see the other script too ? Code (JavaScript): var Health = 100; function ApplyDammage (TheDammage : int) { Health -= TheDammage; if(Health <= 0) { Dead(); } } function Dead() { Destroy (gameObject); }